我想连接到mariaDB与C API https://downloads.mariadb.org/client-native/1.0.0/ 我在Windows 8上,正在使用Code :: Blocks 12.11编译和编写代码。mariadb c api windows未定义的参考
- 我已经把与.H-文件的文件夹中d:\ Programmering \ biblotek \ C \ MariaDB的-API \包括
- 并与d的.lib-文件的文件夹:\ Programmering \ biblotek \ C \ MariaDB的-API \ lib中
所以:
\include has all the .h files
\lib has all the .lib files
LINKING:我做了以下的链接库:
- 连接的\包括文件夹中设置 - >编译器... - >搜索目录 - >编译
- 连接>编译器.. - - >搜索目录 - 在设置的\ lib文件夹>链接
- 连接libmariadb.lib在设置 - >编译器。 - >链接设置
暂停...
- 连接\包括文件夹中项目 - >编译选项... - >搜索目录 - >编译
- 连接\ LIB文件夹中项目 - >编译选项... - >搜索目录 - >链接
- 连接libmariadb.lib在项目 - >编译选项... - >链接设置
在项目 - >构建选项...我有选定的编译器“GNU GCC编译器”。
编译器选项:-g
这是代码:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <C:\MinaProgram\Libs\sqlclientC\include\mysql.h>
#include <my_global.h>
#include <mysql.h>
int main(void) {
MYSQL mysql;
MYSQL_ROW row;
const char *aQuery = "SELECT * from livedata";
if(mysql_library_init(0, NULL, NULL)) { //Initiera bibliotek
fprintf(stderr, "could not initialize MySQL library\n");
exit(1);
}
printf("AH!\n");
MYSQL mysql;
mysql_init(&mysql);
if(!mysql_real_connect(&mysql,"localhost","root","ooops","firsttest",0,NULL,0)) { //Anslut till databas, error meddelande om fel.
fprintf(stderr, "Failed to connect to server!\n");
}
/*GO CODE*/
if(!mysql_real_query(&mysql, aQuery, strlen(aQuery))) {
fprintf(stderr, "Query error, kinda'\n");
}
//mysql_fetch_row()
/*CLOSURE */
mysql_close(&mysql);
mysql_library_end();
return EXIT_SUCCESS;
}
我编译,这是生成日志响应:
||=== test, Release ===|
obj\Release\main.o:main.c:(.text.startup+0x32)||undefined reference to `mysql_library_init'|
obj\Release\main.o:main.c:(.text.startup+0x54)||undefined reference to `[email protected]'|
obj\Release\main.o:main.c:(.text.startup+0x95)||undefined reference to `[email protected]'|
obj\Release\main.o:main.c:(.text.startup+0xb4)||undefined reference to `[email protected]'|
obj\Release\main.o:main.c:(.text.startup+0xeb)||undefined reference to `[email protected]'|
obj\Release\main.o:main.c:(.text.startup+0xf1)||undefined reference to `mysql_library_end'|
||=== Build finished: 6 errors, 0 warnings (0 minutes, 3 seconds) ===|
我已搜查计算器和谷歌并没有发现任何对我有用的东西,所以我希望详细地发布我是如何做错的。
任何想法如何连接到mariaDB与C? (如何使这porgram工作)
亲切的问候!
提示的地球生命时间:不要让Windows 8
这看起来像一个链接错误。什么是构建(链接)命令? – alk 2013-02-14 17:12:32
我使用Build - > Build(Ctrl + F9)。我没有在链接像我张贴的代码块免除任何东西。我实际上不知道链接命令。这是一面旗帜还是我错过了什么? – Dave 2013-02-14 17:34:06