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:
- passing
-D_GLIBCXX_USE_CXX11_ABI=0
to GCC,
- passing
-D_GLIBCXX_USE_CXX11_ABI=1
to GCC,
- setting the macro directly in source code,
- setting the
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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…