mysql和math.h之间的冲突问题

Posted

技术标签:

【中文标题】mysql和math.h之间的冲突问题【英文标题】:Problem with conflict between mysql and math.h 【发布时间】:2008-10-07 15:59:53 【问题描述】:

问题是编译器说在属于 mysql 的库和 std 库中的 math.h 之间有一个函数的重新定义。

我已经解决了两天了,但我仍然无法弄清楚。

有人遇到过这种情况吗?

这是编译器的输出


C:\mingw\bin\mingw32-make.exe 全部 '构建文件:../src/interfaz/ventanaconf.cpp' '调用:GCC C++ 编译器' C:\mingw\bin\mingw32-g++.exe -mms-bitfields -I"c:\dev-cpp\gtkmm\include\gtkmm-2.4" -I"c:\dev-cpp\gtkmm\lib\gtkmm-2.4\include" -I"c:\dev-cpp\gtkmm\include\glibmm-2.4" -I"c:\dev-cpp\gtkmm\lib\glibmm-2.4\include" -I"c:\dev-cpp\gtkmm\include\gdkmm-2.4" -I"c:\dev-cpp\gtkmm\lib\gdkmm-2.4\include" -I"c:\dev-cpp\gtkmm\include\pangomm-1.4" -I"c:\dev-cpp\gtkmm\include\atkmm-1.6" -I"c:\dev-cpp\gtkmm\include\sigc++-2.0" -I"c:\dev-cpp\gtkmm\lib\sigc++-2.0\include" -I"c:\dev-cpp\gtkmm\include\cairomm-1.0" -I"c:\gtk\include\gtk-2.0" -I"c:\gtk\include\glib-2.0" -I"c:\gtk\lib\glib-2.0\include" -I"c:\gtk\lib\gtk-2.0\include" -I"c:\gtk\include\pango-1.0" -I"c:\gtk\include\cairo" -I"c:\gtk\include\freetype2" -I"c:\gtk\include" -I"c:\gtk\include\atk-1.0" -I"c:\Archivos de programa\MySQL\MySQL Server 5.0\include" -O0 -g3 -w -c -fmessage-length=0 -MMD -MP -MF"src/interfaz/ventanaconf.d" -MT“src/interfaz/ventanaconf.d” -o"src/interfaz/ventanaconf.o" "../src/interfaz/ventanaconf.cpp" 在 c:/Archivos de programa/MySQL/MySQL Server 5.0/include/my_global.h:73 包含的文件中, 来自../src/interfaz/../gestiondb/gestordb.h:6, 来自../src/interfaz/../gestiondb/operacionesdb.h:5, 来自../src/interfaz/ventanamodulos.h:20, 来自../src/interfaz/ventanaconf.h:27, 来自../src/interfaz/ventanaconf.cpp:1: c:/Archivos de programa/MySQL/MySQL Server 5.0/include/config-win.h: **在函数`double rint(double)'中: c:/Archivos de programa/MySQL/MySQL Server 5.0/include/config-win.h:228: 错误:重新定义`double rint(double)' C:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:620: **错误: `double rint(double) ' 之前在这里定义过** C:\mingw\bin\mingw32-make.exe: *** [src/interfaz/ventanaconf.o] 错误 1**

提前致谢!!!

【问题讨论】:

【参考方案1】:

mysql 支持区域中的This thread 似乎表明,截至今年 4 月,他们已经从 config_win.h 文件中删除了 rint() 的定义(尽管该补丁是在 2006 年提出的)。您使用的 MySQL 源版本是否比该版本更新?

【讨论】:

我刚刚尝试了这个解决方案,但没有用......我使用的是 MySQL 的旧版本,但是 5.0.51,但在下载 5.0.67 的源代码后,我得到了相同的结果。 好吧,我认为问题在于 config-win.h 旨在实现 rint() 因为大多数 Windows 机器都有错误的舍入行为。但是,看起来您正在使用 mingw/gcc,因此您拥有与任何 *nix 系统相同的 rint()。 ...不知道如何解决这个问题。【参考方案2】:

问题在于包含的库,Linux 简单地忽略了它,但 Windows 想要退出。在linux中放出来也没问题...

有时候我觉得 SOOOOOOOOOOOOOOOOOOOOOOO 愚蠢:..

【讨论】:

【参考方案3】:

在 c:/Archivos de programa/MySQL/MySQL Server 5.0/include/config-win.h 的第 228 行中,您应该找到名为“rint”的函数的声明/定义。在 C:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h 的第 620 行中,您应该找到另一个函数定义相同的名称(甚至可能相同)。

要解决问题,您必须删除/取消注释/取消定义这些定义之一。

如果您还链接两个具有相同功能的库,请准备在链接时遇到类似问题。

【讨论】:

以上是关于mysql和math.h之间的冲突问题的主要内容,如果未能解决你的问题,请参考以下文章

“M_PI_2”: 重复定义的宏

安装MySQL软件包之间存在本地文件冲突怎么解决

开发 C,math.h 问题

PHP:如何访问 phpMyAdmin / php.ini 和 extension_dir 之间的奇怪冲突

有关mysql的for update以及 死锁问题

mysql的各种锁简单总结