2013-03-21 206 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。他們沒有測試過,也不關心與任何現代版本的構建工具的兼容性。