代码之家  ›  专栏  ›  技术社区  ›  Minding Patec

使用cmake从源代码构建MySQL Connector/C++失败(与以前的声明冲突)

  •  -1
  • Minding Patec  · 技术社区  · 7 年前

    我正在尝试使用gcc-8.1.0和cmake3.6.2编译MySQL Connector/C++8.0.12,因为apt包似乎是为gcc-4.9编译的,当与gcc-8.1.0编译程序一起使用时会崩溃(但与gcc-4.9编译程序一起使用)。

    MySQL Documentation

    即使是编译器版本中的一个小更改也会导致问题。如果获得的错误消息可能与二进制不兼容有关,请从源代码中构建Connector/C++,使用与构建和链接应用程序相同的编译器和链接器。

    当我尝试从源代码构建连接器时 here :

    git clone https://github.com/mysql/mysql-connector-cpp.git
    mkdir cppconn
    cd cppconn
    
    cmake /home/pi/mysql-connector-cpp
     # Everything looks fine except for:
    Protobuf include path: /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src
    ...
    -- Performing Test HAVE_IS_SAME - Failed
    
    cmake --build . --target install --config Debug
     # All lot of warings come up and then:
    Scanning dependencies of target protobuf
    ...
    [ 34%] Building CXX object CMakeFiles/protobuf.dir/protobuf-2.6.1/src/google/protobuf/text_format.cc.o
    In file included from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:37:
    /usr/bin/gcc-8.1.0/include/c++/8.1.0/math.h:65:12: error: ‘constexpr bool std::isinf(double)’ conflicts with a previous declaration
     using std::isinf;
                ^~~~~
    In file included from /usr/include/features.h:374,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/os_defines.h:39,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/c++config.h:508,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/utility:68,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/algorithm:60,
                     from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:35:
    /usr/include/arm-linux-gnueabihf/bits/mathcalls.h:201:1: note: previous declaration ‘int isinf(double)’
     __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
     ^~~~~~~~~~~~
    In file included from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:37:
    /usr/bin/gcc-8.1.0/include/c++/8.1.0/math.h:66:12: error: ‘constexpr bool std::isnan(double)’ conflicts with a previous declaration
     using std::isnan;
                ^~~~~
    In file included from /usr/include/features.h:374,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/os_defines.h:39,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/arm-linux-gnueabihf/bits/c++config.h:508,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/utility:68,
                     from /usr/bin/gcc-8.1.0/include/c++/8.1.0/algorithm:60,
                     from /home/pi/mysql-connector-cpp/cdk/protobuf/protobuf-2.6.1/src/google/protobuf/text_format.cc:35:
    /usr/include/arm-linux-gnueabihf/bits/mathcalls.h:234:1: note: previous declaration ‘int isnan(double)’
     __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
    

    合同规定的要求 documentation :

    • 支持C++ 11的C++编译器。在GCC的情况下,它至少必须是版本4.8。这些编译器已经过测试:gcc 4.8.5、5.4.0、6.3.0、6.3.1、7.2.1、7.3.0、8.1.1、clang 9.0.0、MS Visual Studio 2015。
    • CMake 2.8.12或更高版本。 (目前-3.6.2)
    • 如果使用的C++标准库的版本不实现UTF8转换器(CODECDVTUTUF8),则升压1.59或更高版本。构建旧连接器时也需要Boost(见下文)。
    • OpenSSL版本1.0.x,如果连接器是用OpenSSL构建的。连接器/C++可以使用WolfSSL 3.14.0或更新版本来构建,而不是OpenSSL。
    • MySQL8.0客户机库,如果构建遗留连接器(见下文)。 (不需要)

    其他信息:

    • 使用树莓皮2b运行树莓

    提前谢谢。 -留心

    1 回复  |  直到 7 年前
        1
  •  0
  •   Minding Patec    7 年前

    解决方案是使用以下命令正确安装gcc:

    cp -a gcc-*version*/bin/. /usr/bin/
    cp -a gcc-*version*/lib/. /usr/lib/
     # ... (for all sub directories)
    

    它只是将源文件夹的所有文件复制到目标文件夹。

    感谢@Matthieu Brucher告诉我安装错误以及如何正确安装。

    推荐文章