我正在尝试使用gcc-8.1.0和cmake 3.6.2编译MySQL Connector / C ++ 8.0.12,因为apt软件包似乎是为gcc-4.9编译的,当与gcc-8.1一起使用时会崩溃。 0个已编译程序(但可用于gcc-4.9已编译程序)。
即使编译器版本进行很小的更改也会引起问题。如果您获得怀疑与二进制不兼容有关的错误消息,请使用用于构建和链接应用程序的相同编译器和链接器从源代码构建连接器/ 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所述的要求:
其他信息:
先谢谢了。 -思维
答案 0 :(得分:0)
解决方案是使用以下命令正确安装gcc:
cp -a gcc-*version*/bin/. /usr/bin/
cp -a gcc-*version*/lib/. /usr/lib/
# ... (for all sub directories)
这只是将源文件夹的所有文件复制到目标文件夹。
感谢@Matthieu Brucher告诉我我安装错误以及如何正确安装。