Accessing MySQL server from C programme
Accessing MySQL server from C programme
- Subject: Accessing MySQL server from C programme
- From: "D.K. Johnston" <email@hidden>
- Date: Sat, 31 Mar 2007 20:38:41 -0700
I'm trying to connect to a MySQL server from a C programme. I've set
the search paths in the XCode project to /usr/local/mysql/include
and /usr/local/mysql/lib. The code compiles and links without
complaint. I've looked in the directories, and the required headers
and libraries seem to all be present. But when I run the programme I
get this:
ZeroLink: unknown symbol '_mysql_init'
cMySQL has exited due to signal 6 (SIGABRT).
I'd be very grateful if someone would explain to me what's going on
here. Why doesn't the unknown symbol error show up during linking?
Here's the code I'm using. It's from pp.357 of MySQL (3rd ed.) by
Paul DuBois.
#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>
static char *opt_host_name = NULL;
static char *opt_user_name = NULL;
static char *opt_password = NULL;
static unsigned int opt_port_num = 0;
static char *opt_socket_name = NULL;
static char *opt_db_name = NULL;
static unsigned int opt_flags = 0;
static MYSQL *conn;
int main (int argc, const char * argv[])
{
// initialise connection handler
conn = mysql_init( NULL );
if( conn == NULL )
{
fprintf( stderr, "mysql_init() failed \n" );
exit( 1 );
}
// connect to server
if( mysql_real_connect( conn, opt_host_name, opt_user_name,
opt_password, opt_db_name, opt_port_num,
opt_socket_name, opt_flags ) == NULL )
{
fprintf( stderr, "mysql_real_connect() failed \n" );
exit( 1 );
}
// disconnect from server
mysql_close( conn );
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden