Reputation: 279
I got a problem with the new ABI introduced for C++11 in GCC. After upgrading to GCC 5.3 my project does no longer compile. The error messages I get are simple:
undefined reference to `tokenize(std::__cxx11::basic_string' ...more characters
or
undefined reference to `extract(std::string const&)'
So, it looks like I messed something up and GCC is unable to decide whether I want the old ABI or the new one (the __cxx11::
part is missing from some error messages, and present in others)?
I tried several solutions to resolve the issue:
-D_GLIBCXX_USE_CXX11_ABI=0
to GCC,-D_GLIBCXX_USE_CXX11_ABI=1
to GCC,abi_tag
attribute on the declarations GCC complained about when passed the -Wabi-tag
flag,Unfortunately, neither of them worked (i.e. allowed the code to compile). The one thing I know is that only functions returning std::string
or taking it as a parameter fail to link. Which is to be expected, given what I read about the problem on the Internet. I was unable to reproduce the issue in a simple, example program to present it here.
Is there any obvious solution to my problem, that I am missing?
Upvotes: 6
Views: 5623
Reputation: 118415
This error indicates that you're linking to some code or library that has not been recompiled by gcc 5.3, and was compiled by an earlier version of gcc, using the earlier version of the ABI.
If you are linking with some external libraries, besides the standard C++ library, those external libraries need to be recompiled (and reinstalled).
If you are not linking with any external libraries, and you are only linking together your own code, some of your source modules must not've been recompiled yet. Recompile everything. Make sure to wipe all existing object modules, with make clean
, or the equivalent for whatever build system you're using.
Upvotes: 9