Mysql与C ++错误:未定义的引用mysql_init [英] Mysql with C++ error: undefined reference to mysql_init
本文介绍了Mysql与C ++错误:未定义的引用mysql_init的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdlib.h>
#include <mysql.h>
#include <my_global.h>
int main (int argc, char *argv[])
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "127.0.0.1";
char *user = "root";
char *password = "1386";
char *database = "OurDB";
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(0);
}
return 0;
}
我在代码块中得到链接器错误:
and i get linker error in codeblocks:
undefined reference to mysql_init
I在编译器选项中使用 mysql_config --libs
和 mysql_config --cflags
。
I used mysql_config --libs
in linker option and mysql_config --cflags
in compiler option.
我读某处我应该添加一些库libmysql.lib,但我不能在我的电脑上找到这个文件(我使用Ubuntu 11.04 64位)。
I read somewhere i should add some libraries like libmysql.lib, but i cannot find this file on my PC (I am using Ubuntu 11.04 64bit).
推荐答案
设置 - >编译器和调试器 - >搜索目录 - >链接器
,然后添加,并插入 / usr / lib / mysql /
Setting -> Compiler and debugger -> Search directories -> Linker
then Add and insert /usr/lib/mysql/
这篇关于Mysql与C ++错误:未定义的引用mysql_init的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文