2013-03-21 186 views
0

我在编译mysql连接器时遇到了一个问题,用官方网站发布的mingw,你应该运行cmake来配置源码,然后运行一个mingw32-make ...该cmake需要安装boost库,所以我得到它并编译它(它说很多更新,40个目标跳过,无法更新24)。编译mysql连接器用mingw编译C++,编译错误

之后,试图在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 
+0

大多数是警告,唯一的错误似乎是围绕ui64型或编译器标志。也许mingw32-make版本不正确? – nonsensickle 2013-03-21 22:45:34

+0

你是什么意思?你相信这个问题是在mingw32-make?我使用的灌输上的Qt MinGW的版本,所以我应该安装新的MinGW或安装另一种化妆工具(cmake的可以建立NMAKE,mingw32的,化妆,做等等)?感谢您的评论 – user1553386 2013-03-22 05:45:47

回答

0

MySQL的连接器C++源代码是垃圾,可惜。

它重新定义在标准库中定义的函数,然后包括标准库,或依赖于不包括在每一个实现非标准功能。

由于标准库不检查,看看它的功能和结构已经确定,你结束了多个定义错误所有的地方。

另外,由于mysql连接器尚未被移植到mingw,所以问题会变得更糟。要在Windows上编译,您需要使用Visual Studio。

它变得更好。他们只支持Visual Studio的8和9

如果您按照这些说明准确, http://dev.mysql.com/doc/connector-cpp/en/connector-cpp-installation-source-windows.html ,那么你也许可以得到它的工作,但你不能从任何版本号偏离。使用旧版本的cmake,旧版本的visual studio。他们没有测试过,也不关心与任何现代版本的构建工具的兼容性。