关于Linux 8.0, Mysql, c编译错误的问题.大侠们帮忙阿!
我用C语言编写了一个非常简单的程序,语法等都没有问题(自我感觉如此),但是编译的时候MYSQL的代码库却出了错误,哪位大侠看看是什么问题?
程序如下
#include "mysql.h"
#include <assert.h>
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
main(int argc,char *argv[])
{
//MYSQL mysql;
//MYSQL_RES *res;
//MYSQL_ROW row;
assert(mysql_init(&mysql)!=NULL);
if(mysql_real_connect(&mysql,NULL,NULL,NULL,NULL,0,NULL,0)==NULL)
{
fprintf(stderr,"error on connect: %s
",mysql_error(&mysql));
exit(EXIT_FAILURE);
}
if(mysql_real_query(&mysql,"SHOW DATABASES",14)!=0)
{
fprintf(stderr,"error on query: %s
",mysql_error(&mysql));
exit(EXIT_FAILURE);
}
if((res=mysql_store_result(&mysql))==NULL)
{
fprintf(stderr,"error on store: %s
",mysql_error(&mysql));
exit(EXIT_FAILURE);
}
printf("Database:
");
while((row=mysql_fetch_row(res)))
{
printf(" %s
",row[0]);
}
mysql_free_result(res);
mysql_close(&mysql);
// exit(EXIT_SUCCESS);
}
编译命令行如下
gcc -I/usr/include/mysql -L/usr/lib/mysql db.c -lmysqlclient lm
错误如下
/usr/lib/mysql/libmysqlclient.a(my_compress.o): In funtion 'my_uncompress';
my_compress.0(.text+0xaa):undefined reserence to 'uncompress' /usr/lib/mysql/libmysqlclient.a(my_compress.o): In function 'my_compress_alloc';
my_compress.o(.text+0x13c): undefined reference to 'compress'
collect2: ld returned 1 exit status