undefined reference to `std::__cxx11::basic_string in Boost on Travis CI

时间秒杀一切 提交于 2020-01-01 19:42:16

问题


I am trying to get a C+++ project which uses Boost on GitHub to compile correctly on Travis CI.

First I tried the packages and PPAs on ubuntu, but they were too old(I need at least Boost 1.61).

I got it to work only if I compiled Boost on Travis CI(download, compile), but, unfortunately, the compile time is big (11-18 mins) and the log file is just huge.

Thinking how to get over this issues, I thinked about compiling boost on my machine, zipping, uploading to some web server and just downloading and copying on /usr/local/[include/lib] the corresponding files.

Here is the compiler I used on my machine. I compiled boost using

./bootstrap.sh --prefix=/home/andrei/boostabc
/usr/bin/time ./b2 install link=static

Here is the travis file (and repository). In comments is the way I did it with compiling boost.

The problem is that I get a lot of errors:

/usr/local/lib/libboost_filesystem.a(operations.o): In function `(anonymous namespace)::dir_itr_first(void*&, void*&, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::filesystem::file_status&, boost::filesystem::file_status&) [clone .isra.46] [clone .constprop.56]':
operations.cpp:(.text+0xa8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

I googled this errors and I found there might be a misconfig about some C++11 ABI and a macro. I didn't understand very well the explanation and I do not have any idea how to get it working.

I would be grateful if you could point me in the right direction of solving this.


回答1:


You should try the adding -D_GLIBCXX_USE_CXX11_ABI=0 to the command line used to compile it, and see if this gets rid of the problem.

I think its quite possible that one or other of the g++/gcc you are calling is not version 6 ... otherwise this would be set to 1 by default iirc.

This is documented here




回答2:


Maybe ISO C++ doesn't support it, according to the result of linker.You can try compile with g++ yourfiles.cc -std=c++11



来源:https://stackoverflow.com/questions/44241667/can-i-compile-using-a-specific-gcc-version-like-gcc4-1-under-gcc-5-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!