开发者

MySQL C API compilation error, crtdbg.h not found

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 <stdio.h>
#include <my_global.h>
#include <mysql.h>

int main(int argc, char *argv[]) {
    printf("Hello World\n");
    return 0;
}

If no one is able to help me out with that problem, c开发者_JAVA技巧ould 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜