我正在尝试编译以下内容:
#include <stdio.h>
#include <stdlib.h>
#include <my_global.h>
#include <mysql.h>
int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
printf("MySQL client version: %s\n", mysql_get_client_info());
return EXIT_SUCCESS;
}
但是,Eclipse正在提供以下错误消息:
构建目标:TestConsole4
调用:GCC C Linker
gcc -L / usr / include -L / usr / include / mysql -o“TestConsole4”./ src / TestConsole4.o
./src/TestConsole4.o:在函数main':
/home/hearme/workspace/TestConsole4/Debug/../src/TestConsole4.c:19: undefined reference to
中mysql_get_client_info'
collect2:ld返回1退出状态
make:*** [TestConsole4]错误1
我一直在四处寻找解决这个问题的想法吗?
由于
答案 0 :(得分:2)
From the MySQL reference manual:
"MySQL clients must be linked using the -lmysqlclient -lz options in the link command. You may also need to specify a -L option to tell the linker where to find the library. For example, if the library is installed in /usr/local/mysql/lib, use these options in the link command:
-L/usr/local/mysql/lib -lmysqlclient -lz"