有人曾经做过这件事吗???
我正在尝试使用MinGW使用MySQL库编译程序。我不断收到重新定义函数'rint'的消息。好的,这个函数在两个文件中都是config-win.h,来自MySQL和math.h来自标准库,但是它们都被认为是没有问题的库。
在我打破了一会儿后,我甚至尝试了这个,不会编译:
#include <iostream>
#include <my_global.h>
#include <mysql.h>
using namespace std;
int main() {
cout << "Hello World!!!" << endl; // prints Hello World!!!
return 0;
}
这是命令以及编译
的输出问题i586-mingw32msvc-cc -I / usr / include / mysql probando.cpp -w
In file included from /usr/include/mysql/my_global.h:73,
from probando.cpp:10:
/usr/include/mysql/config-win.h: In function ‘double rint(double)’:
/usr/include/mysql/config-win.h:229: error: redefinition of ‘double rint(double)’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/math.h:635: error: ‘double rint(double)’ previously defined here
我已经在WindowsXP中使用MinGW进行了测试,在.a库和Linux中正确地转换了MySQL库(输出来自Linux,与Windows完全相同),使用MinGW32。
人......我的选择已经用完......任何线索?有人曾经使用过MySQL和MinGW吗?可以和Cygwin一起工作吗?
如果你花时间回答,请提前致谢。
答案 0 :(得分:1)
同样是一个猜测,但似乎math.h和config-win.h有一个名为rint的函数,确保没有两个具有相同名称的函数。
顺便说一句,因为我不完全确定,我正在编辑这个社区,如果我不对,请随时编辑这篇文章。答案 1 :(得分:0)
我不知道有问题的堆栈,但我的猜测是,math.h正在以双重包含。看一下math.h文件。靠近顶部的地方应该有一个include guard。如果您不熟悉包含守卫的概念,请点击链接。在这两个地方你都应该使用include guard来包含math.h。
您也可以查找特定于Linux的#defines;由于#define在某处,该文件可能不会在Linux上包含两次。
正如我所说,这只是猜测。
答案 2 :(得分:0)
好的,我解决了。
我的愚蠢是包含错误的文件。要在mingw中执行此操作,您必须#include&lt; windows.h&gt;而不是&lt; config-win.h&gt;
非常感谢!!!