undefined reference to 'mysql_init'
Hi, I am begeener to MySQL. I have installed Suse10 and MySQL and mysql++ in my pc. i want to connect to MySQL through C. When I am compiling the program, I am getting the following error. *** gcc -o test test.c test.c:28:3: warning: no newline at end of file /tmp/cchl7IEh.o: In function `main': test.c:(.text+0x22): undefined reference to `mysql_init' test.c:(.text+0x4f): undefined reference to `mysql_real_connect' test.c:(.text+0x65): undefined reference to `mysql_query' test.c:(.text+0x76): undefined reference to `mysql_store_result' test.c:(.text+0x87): undefined reference to `mysql_num_rows' test.c:(.text+0xdc): undefined reference to `ltmysql_num_fields' test.c:(.text+0xf1): undefined reference to `mysql_fetch_row' test.c:(.text+0x10b): undefined reference to `mysql_close' collect2: ld returned 1 exit status *** The code is as fillows: *** #include stdio.h #include mysql.h #define host localhost #define username mysql #define password #define database test MYSQL *conn; int main() { conn = mysql_init(NULL); mysql_real_connect(conn,host,username,password,database,0,NULL,0); MYSQL_RES *res_set; MYSQL_ROW row; unsigned int i; mysql_query(conn,SELECT * FROM users WHERE userid=1); res_set = mysql_store_result(conn); unsigned int numrows = mysql_num_rows(res_set); while ((row = mysql_fetch_row(res_set)) != NULL) { for (i=0; iltmysql_num_fields(res_set); i++) { printf(%s\n,row[i] != NULL ? row[i] : NULL); } } mysql_close(conn); return 0; } * Please help me in this regard. - Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
Re: undefined reference to 'mysql_init'
Try gcc -o test test.c -lmysqlclient On Sunday 23 July 2006 13:14, ali asghar torabi parizy wrote: Hi, I am begeener to MySQL. I have installed Suse10 and MySQL and mysql++ in my pc. i want to connect to MySQL through C. When I am compiling the program, I am getting the following error. *** gcc -o test test.c test.c:28:3: warning: no newline at end of file /tmp/cchl7IEh.o: In function `main': test.c:(.text+0x22): undefined reference to `mysql_init' test.c:(.text+0x4f): undefined reference to `mysql_real_connect' test.c:(.text+0x65): undefined reference to `mysql_query' test.c:(.text+0x76): undefined reference to `mysql_store_result' test.c:(.text+0x87): undefined reference to `mysql_num_rows' test.c:(.text+0xdc): undefined reference to `ltmysql_num_fields' test.c:(.text+0xf1): undefined reference to `mysql_fetch_row' test.c:(.text+0x10b): undefined reference to `mysql_close' collect2: ld returned 1 exit status *** The code is as fillows: *** #include stdio.h #include mysql.h #define host localhost #define username mysql #define password #define database test MYSQL *conn; int main() { conn = mysql_init(NULL); mysql_real_connect(conn,host,username,password,database,0,NULL,0); MYSQL_RES *res_set; MYSQL_ROW row; unsigned int i; mysql_query(conn,SELECT * FROM users WHERE userid=1); res_set = mysql_store_result(conn); unsigned int numrows = mysql_num_rows(res_set); while ((row = mysql_fetch_row(res_set)) != NULL) { for (i=0; iltmysql_num_fields(res_set); i++) { printf(%s\n,row[i] != NULL ? row[i] : NULL); } } mysql_close(conn); return 0; } * Please help me in this regard. - Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less. -- Mike Aubury -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: undefined reference to 'mysql_init'
Hi Ali Hi, I am begeener to MySQL. I have installed Suse10 and MySQL and mysql++ in my pc. i want to connect to MySQL through C. When I am compiling the program, I am getting the following error. *** compile your app with the command bellow gcc -o test -L/usr/lib/mysql -lmysqlclient test.c Regards Luiz -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]