Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I coded a c program (mysqlc.c) to access the mysql database and dump the results. The program is given below.
=============================================
#include <mysql.h>
#include <stdio.h>int main(void) {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
/* Change me */
char *server = "leuscs03";
char *user = "guest";
char *password = "setnew1";
char *database = "mysql";conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}res = mysql_use_result(conn);
/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);/* close connection */
mysql_free_result(res);
mysql_close(conn);return 0;
}
=============================================I am using the following command to compile the program mysqlc.c.
=============================================
/usr/bin/gcc -o mysqlc.exe -I/usr/local/bin/mysql/include -g -DUNIV_AIX mysqlc.c -L/usr/local/bin/mysql/lib -lmysqlclient -lz -lrt -lnsl_r
=============================================mysql is installed under /usr/local/bin instead of /usr/local in our box.
During compilation, I am getting the following error messages.
=============================================
mysqlc.c: In function 'main':
mysqlc.c:25: warning: incompatible implicit declaration of built-in function 'exit'
mysqlc.c:31: warning: incompatible implicit declaration of built-in function 'exit'
ld: 0711-317 ERROR: Undefined symbol: .mysql_init
ld: 0711-317 ERROR: Undefined symbol: .mysql_real_connect
ld: 0711-317 ERROR: Undefined symbol: .mysql_error
ld: 0711-317 ERROR: Undefined symbol: .mysql_query
ld: 0711-317 ERROR: Undefined symbol: .mysql_use_result
ld: 0711-317 ERROR: Undefined symbol: .mysql_fetch_row
ld: 0711-317 ERROR: Undefined symbol: .mysql_free_result
ld: 0711-317 ERROR: Undefined symbol: .mysql_close
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information
collect2: ld returned 8 exit status
=============================================I did some reading and it looks like all the above methods are supposed to be in the libmysqlclient.a and I could see that this file is available under /usr/local/bin/mysql/lib and I am passing this to the linker using the -L option.
Can some one help me how to resolve this issue?
Thanks,
Balaji.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |