steph291


Group: Members
Posts: 20
Joined: Oct. 2003 |
 |
Posted: Sep. 27 2007,03:04 |
 |
Hi everyone, My problem is I cannot communicate with mysql server using C api and gcc. Every references to mysql functions return errors.
I have modified my ld.so.conf to include the path to libmysqlclient (/opt/lampp/lib/mysql) then ldconfig. but it's not helping, please help !!!
titou@server1:~$ gcc meteotest.c /tmp/ccSjdnBl.o(.text+0x1d): In function `main': : undefined reference to `mysql_init' /tmp/ccSjdnBl.o(.text+0x43): In function `main': : undefined reference to `mysql_connect' /tmp/ccSjdnBl.o(.text+0x6c): In function `main': : undefined reference to `mysql_select_db' /tmp/ccSjdnBl.o(.text+0x7e): In function `main': : undefined reference to `mysql_close' /tmp/ccSjdnBl.o(.text+0xa3): In function `main': : undefined reference to `mysql_query' /tmp/ccSjdnBl.o(.text+0xb1): In function `main': : undefined reference to `mysql_use_result' /tmp/ccSjdnBl.o(.text+0xc5): In function `main': : undefined reference to `mysql_fetch_row' /tmp/ccSjdnBl.o(.text+0x10e): In function `main': : undefined reference to `mysql_close' collect2: ld returned 1 exit status
here's the source : #include <stdio.h> #include "/home/titou/mysql.h"
#define MYSQL_HOST "localhost" #define MYSQL_DB "meteo" #define MYSQL_LOGIN "duh!" #define MYSQL_PASSWD "duh!"
int main() { MYSQL mysql; MYSQL_RES *result; MYSQL_ROW row;
mysql_init(&mysql); if (!mysql_connect(&mysql,MYSQL_HOST,MYSQL_LOGIN,MYSQL_PASSWD)) { return -1; } if (mysql_select_db(&mysql,MYSQL_DB)) { mysql_close(&mysql); return -1; } mysql_query(&mysql,"SELECT * FROM meteoraw"); result = mysql_use_result(&mysql); while((row = mysql_fetch_row(result))) { printf("%s",row[1]); fflush(stdout); } mysql_close(&mysql); return 0; }
-------------- smarchan291 Rouyn, Quebec, Canada Proud Internet Coder
|