我当前正在尝试在CentOS 7上编译我的程序,但发生了下面的错误。
它在ubuntu18.04上运行得很好,但不能在CentOS 7上运行。
db/obj-db.o: In function `std::vector<std::string, std::allocator<std::string> >::_M_range_check(unsigned long) const':
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_vector.h:825: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
db/obj-db.o: In function `std::vector<int, std::allocator<int> >::_M_range_check(unsigned long) const':
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_vector.h:825: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
../bin/x64/libUFMatcher.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
../bin/x64/libUFMatcher.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
collect2: error: ld returned 1 exit status
make: *** [Makefile:56: ../bin/x64/MatchingServer] Error 1发布于 2021-05-10 23:48:18
Centos7有一个旧的gcc版本,可能是4.8.5。但现在很多库都需要更高的版本。您可以运行以下命令以使用更高的gcc版本
sudo yum update -y
sudo yum install centos-release-scl
sudo yum install devtoolset-8 # gcc 8 is part of this toolset
scl enable devtoolset-8 bash # make the gcc version be 8.3.1发布于 2021-09-10 09:20:06
检查链接的目标(object/lib)是否使用相同版本的gcc编译。
https://stackoverflow.com/questions/56768173
复制相似问题