【问题标题】:Compiling in c++ with mysql, pthreads and gtk用 mysql、pthreads 和 gtk 在 C++ 中编译
【发布时间】:2008-10-07 11:03:32
【问题描述】:

以前有人做过吗???

我正在尝试使用 MinGW 来编译使用 MySQL 库的程序。我不断收到重新定义函数“rint”的消息。好的,该函数确实在 MySQL 的 config-win.h 和标准库的 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 进行了测试,MySQL 库在 .a 库中正确转换,在 Linux(输出来自 Linux,与 Windows 中几乎相同)中使用 MinGW32。

人们...我没有选择...任何线索?有人以前使用过 MySQL 和 MinGW 吗?它可以与 Cygwin 一起使用吗?

如果您花时间回答,请提前感谢。

【问题讨论】:

    标签: mysql windows boolean math.h


    【解决方案1】:

    也是一个猜测,但似乎 math.h 和 config-win.h 有一个名为 rint 的函数,请确保没有两个同名的函数。

    顺便说一句,因为我不完全确定,我让这个社区可编辑,如果我不正确,请随时编辑这篇文章。

    【讨论】:

      【解决方案2】:

      我不知道有问题的堆栈,但我的猜测是 math.h 会以某种方式被包含在内。查看 math.h 文件。靠近顶部的某个地方应该有一个include guard。如果您不熟悉包含保护的概念,请点击链接。在这两个地方,您都应该使用 include 保护来包含 math.h。

      您还可以查找特定于 Linux 的#define;由于某处的#define,该文件可能不会在Linux上包含两次。

      正如我所说,这只是一个猜测。

      【讨论】:

        【解决方案3】:

        好的,我解决了。

        我的愚蠢之处在于包含了错误的文件。要在 mingw 中执行此操作,您必须 #include 而不是

        还是谢谢!!!

        【讨论】:

          猜你喜欢
          • 2011-01-10
          • 1970-01-01
          • 1970-01-01
          • 2013-02-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-03-13
          相关资源
          最近更新 更多