我目前正在尝试在 CentOS 7 上编译我的程序,但出现了以下错误。
它适用于 ubuntu 18.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
最佳答案
centos 7 有一个旧的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
关于linux - devtoolset-7 STL_vector.h 未定义对 `std::__throw_out_of_range_fmt(char const*, ...)' 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56768173/