devtoolset-7 stl_vector.h未定义对`std :: __ throw_out_of_range_fmt(char const *,...)'的引用

时间:2019-06-26 08:12:15

标签: linux undefined centos7 stdvector libstdc++

我目前正在尝试在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

1 个答案:

答案 0 :(得分:0)

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