mysql api编译,MySQL C API编译错误,找不到crtdbg.h

I'm creating a basic C program that uses the mysql api. I'm on windows, using mingw as my compiler and eclipse cdt as my IDE. I have added the include path to the mysql include files and the lib path to the mysqlclient.lib file.

However, I get this error:

D:\Programs\MinGW\include\mysql/my_dbug.h:108:20: fatal error: crtdbg.h: No such file or directory

Here is my code:

#include

#include

#include

int main(int argc, char *argv[]) {

printf("Hello World\n");

return 0;

}

If no one is able to help me out with that problem, could someone tell me what the difference is between using mysqlclient.lib and libmysql.lib/libmysql.dll?

Cheers.

解决方案

I am afraid that there is no crtdbg.h in MinGW distribution. I think that on Windows, this header comes with Microsoft's compiler. I believe that you could also use Cygwin instead of Micrsoft's compiler, since compiling MySql on Windows is only possible with Cygwin or Microsoft's compiler (MinGW is not supported), so in theory Cygwin should be able to compile your program.

You can also get Microsoft's compiler for free by installing Windows SDK.

If no one is able to help me out with that problem, could someone tell me what the difference is between using mysqlclient.lib and libmysql.lib/libmysql.dll?

mysqlclient.lib should be static library and libmysql.lib/libmysql.dll is dynamic library.

NOTE: If you want to use static library with microsoft's compiler then it must be compiled with same compiler (and same version too) as you program. You can find more information about compiling on windows here. Look at the last section Compiling MySQL Clients on Microsoft Windows

UPDATE: Using Microsoft's compiler you can compile you code by using following command:

cl mysource.c /IC:\Path\To\MySql\Include\Directory /link /LIBPATH:C:\Path\To\MySql\Lib\Directory /DEFAULTLIB:libmysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值