http://www.mysql.com/doc/en/mysql_connect.html
This function is deprecated. It is preferable to use
mysql_real_connect() instead.
#include<stdio.h>
#include<mysql.h>
int main(void) {
MYSQL mysql;
if(mysql_init(&mysql) == NULL) {
fprintf(stderr,"Unable to initlize MySQL structure.\n");
return(1);
}
if(mysql_real_connect(&mysql,"127.0.0.1","user","password", "db", 0,
NULL, 0) == NULL) {
fprintf(stderr,"Unable to connect to MySQL: %s\n",
mysql_error(&mysql));
return(1);
}
return(0);
}
mybox:/home/nickgsu > gcc seeLog.c -o seeLog -I/usr/local/mysql/include
-L/usr/local/mysql/lib -lmysqlclient -lz
mybox:/home/nickgsu > ./seeLog
Unable to connect to MySQL: Access denied for user: '[EMAIL PROTECTED]'
(Using password: YES)
Good luck,
nickg
-----Original Message-----
From: hAj [mailto:[EMAIL PROTECTED]
Sent: Monday, November 10, 2003 4:03 PM
To: [EMAIL PROTECTED]
Subject: C API: undefined reference
Hello MySQL pros worldwide,
~/www ->cat seeLog.c
#define USE_OLD_FUNCTIONS
#include <stdio.h>
#include <mysql/mysql.h>
int main() {
MYSQL mysql;
MYSQL *mysqldb = NULL;
mysqldb = mysql_connect(&mysql, "geneofcube.net", "USERID",
"PASSWORD");
return 0;
}
~/www ->gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient
/tmp/ccEj3tmv.o: In function `main':
/tmp/ccEj3tmv.o(.text+0x2a): undefined reference to `mysql_connect'
collect2: ld returned 1 exit status
~/www ->
As shown above, I'm having a problem getting rid of a compilation error
(undefined reference) coming out with a very simple c code (seeLog.c)
which
I wrote for a testing purpose.
Got no I idea what I'm doing wrong or missing here.
I'd appreciate any of your suggestions.
Best,
hAj
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]