MySQL C API编译错误,找不到crtdbg.h [英] MySQL C API compilation error, crtdbg.h not found

查看:460
本文介绍了MySQL C API编译错误,找不到crtdbg.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用mysql API的基本C程序.我在Windows上,使用mingw作为我的编译器,并使用eclipse cdt作为我的IDE.我已经将包含路径添加到mysql包含文件中,并将lib路径添加到了mysqlclient.lib文件中. 但是,出现此错误:

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

这是我的代码:

#include <stdio.h>
#include <my_global.h>
#include <mysql.h>

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

如果没有人能够帮助我解决该问题,有人可以告诉我使用mysqlclient.lib和libmysql.lib/libmysql.dll有什么区别吗?

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?

干杯.

推荐答案

恐怕MinGW发行版中没有crtdbg.h.我认为在Windows上,此标头随Microsoft的编译器一起提供.我相信您也可以使用Cygwin而不是Micrsoft的编译器,因为只有使用Cygwin或Microsoft的编译器(不支持MinGW)才能在Windows上编译MySql,因此从理论上讲Cygwin应该能够编译您的程序.

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.

您还可以通过安装Windows SDK免费获得Microsoft的编译器.

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

如果没有人能够帮助我解决该问题,有人可以告诉我使用mysqlclient.lib和libmysql.lib/libmysql.dll有什么区别吗?

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应该是静态库,而libmysql.lib/libmysql.dll是动态库.

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

注意::如果要将静态库与Microsoft的编译器一起使用,则必须使用与程序相同的编译器(以及相同的版本)对其进行编译.您可以在此处找到有关在Windows上编译的更多信息.请看最后一节在Microsoft Windows上编译MySQL客户端

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

更新:使用Microsoft的编译器,您可以使用以下命令来编译代码:

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

这篇关于MySQL C API编译错误,找不到crtdbg.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆