0

我在用 mingw 编译 mysql 连接器 C++ 时遇到问题,正如官方网站上所发布的,你应该运行 cmake 来配置源代码,然后运行 ​​mingw32-make ... cmake 需要安装 boost 库,所以我得到它并编译它(它说许多更新,40个目标被跳过并且未能更新24个)。

之后尝试在 mysql 连接器源上运行 cmake,它没有输出任何错误并且工作正常,当尝试执行最后一步 mingw32-make 时,它​​给出了很多错误,其中许多是重新定义......日志如下。请帮助我,我真的需要它。

    C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\bin>mingw32-make
    [  0%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.cpp.obj
    C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:1:0: warning: -fPIC
     ignored for target (all code is position independent) [enabled by default]
    In file included from C:/MySQL/MySQL_Server_5.6/include/my_global.h:72:0,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\nativeapi/mysql_private_iface.h:57,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_util.h:30,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:31:
    C:/MySQL/MySQL_Server_5.6/include/my_config.h:509:0: warning: "isnan" redefined [enabled by default]

    In file included from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:28:0:
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/math.h:480:0: note: this is the location of the previous definition
    In file included from C:/MySQL/MySQL_Server_5.6/include/my_global.h:72:0,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\nativeapi/mysql_private_iface.h:57,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_util.h:30,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:31:
    C:/MySQL/MySQL_Server_5.6/include/my_config.h:517:0: warning: "strtok_r" redefined [enabled by default]
    In file included from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/i686-w64-mingw32/bits/gthr-default.h:41:0,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/i686-w64-mingw32/bits/gthr.h:150,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/ext/atomicity.h:34,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/bits/ios_base.h:41,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/ios:43,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/istream:40,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/sstream:39,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:27:
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/pthread.h:460:0: note: this is the location of the previous definition
    In file included from C:/MySQL/MySQL_Server_5.6/include/my_global.h:72:0,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\nativeapi/mysql_private_iface.h:57,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_util.h:30,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:31:
    C:/MySQL/MySQL_Server_5.6/include/my_config.h:527:0: warning: "NOMINMAX" redefined [enabled by default]
    In file included from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/i686-w64-mingw32/bits/c++config.h:414:0,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/iosfwd:40,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/ios:39,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/istream:40,
                     from c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/sstream:39,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:27:
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/i686-w64-mingw32/bits/os_defines.h:46:0: note: this is the location of the previous definition
    In file included from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_util.h:30:0,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:31:
    C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\nativeapi/mysql_private_iface.h:81:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
    In file included from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.c
    pp:36:0:
    C:/Users/Hugo/Downloads/mysql-connector-c++-1.1.2/cppconn/exception.h:48:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
    C:/Users/Hugo/Downloads/mysql-connector-c++-1.1.2/cppconn/exception.h:52:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
    C:/Users/Hugo/Downloads/mysql-connector-c++-1.1.2/cppconn/exception.h:53:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
    C:/Users/Hugo/Downloads/mysql-connector-c++-1.1.2/cppconn/exception.h:58:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
    C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:162:1: error: invalid suffix "ui64" on integer constant
    C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:162:1: error: invalid suffix "ui64" on integer constant
    In file included from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\nativeapi/mysql_private_iface.h:57:0,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_util.h:30,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:31:
    C:/MySQL/MySQL_Server_5.6/include/my_global.h: In function 'double rint(double)':
    C:/MySQL/MySQL_Server_5.6/include/my_global.h:1160:35: error: 'double rint(double)' was declared 'extern' and later 'static' [-fpermissive]
    In file included from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:28:0:
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/math.h:783:23: error: previous declaration of 'double rint(double)' [-fpermissive]
    In file included from D:/boost_1_53_0/boost/assert.hpp:81:0,
                     from D:/boost_1_53_0/boost/smart_ptr/shared_ptr.hpp:29,
                     from D:/boost_1_53_0/boost/shared_ptr.hpp:17,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_util.h:33,
                     from C:\Users\Hugo\Downloads\mysql-connector-c++-1.1.2\driver\mysql_art_resultset.cpp:31:
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/cstdlib: At global scope:
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/cstdlib:196:11: error: '::strtoll' has not been declared
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/cstdlib:197:11: error: '::strtoull' has not been declared
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/cstdlib:219:22: error: '__gnu_cxx::strtoll' has not been declared
    c:\qt\qt5.0.1\tools\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include/c++/cstdlib:220:22: error: '__gnu_cxx::strtoull' has not been declared
    driver\CMakeFiles\mysqlcppconn.dir\build.make:57: recipe for target 'driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.cpp.obj' failed
    mingw32-make[2]: *** [driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.cpp.obj] Error 1
    CMakeFiles\Makefile2:94: recipe for target 'driver/CMakeFiles/mysqlcppconn.dir/all' failed
    mingw32-make[1]: *** [driver/CMakeFiles/mysqlcppconn.dir/all] Error 2
    makefile:135: recipe for target 'all' failed
    mingw32-make: *** [all] Error 2
4

1 回答 1

0

不幸的是,mysql连接器c ++源代码是垃圾。

它重新定义了标准库中定义的函数,然后包含标准库,或者依赖于未包含在每个实现中的非标准函数。

由于标准库不检查其函数和结构是否已经定义,因此您最终会遇到多个定义错误。

此外,由于尚未为 mingw 移植 mysql 连接器,因此问题变得更糟。要在 Windows 上编译,您需要使用 Visual Studio。

它变得更好了。它们仅支持 Visual Studio 8 和 9。

如果您完全按照这些说明进行操作, http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-installation-source-windows.html 那么您也许可以让它工作,但您必须不偏离任何版本号。使用旧版本的 cmake,旧版本的 Visual Studio。他们没有测试过,也不关心与任何现代版本的构建工具的兼容性。

于 2015-02-08T23:10:56.793 回答