问题
I recently updated Ubuntu from 15.04 to 15.10. One of the major differences between these versions is the update of the default gcc version from gcc-4.9 -> gcc-5. The library I'm developing has been written and compiled for gcc-4.9, and relies on other libraries which only work in gcc-4.9.
I have installed gcc-4.9 onto my computer, and I can successfully compile both the library and my source file. However, when I tried to run the resultant program I get this error:
terminate called after throwing an instance of 'std::ios_base::failure[abi:cxx11]'
what(): basic_ios::clear: iostream error
Aborted (core dumped)`
The source code, and the file I'm trying to read here used to work before the upgrade. I have tried using the -D_GLIBCXX_USE_CXX11_ABI=0
flag, but I'm not sure this is the right thing to do, also it doesn't work.
This is an example of the flags I'm currently including in my makefile:
CPPFLAGS = -O0 -g3 -Wall -c -fpermissive -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++0x -fPIC -MMD -MP
Any ideas that might help me out?
回答1:
You "simply" need to recompile everything your program needs that is C++.
See eg the Debian wiki on the transision which has (inter alia)
The good news is, that GCC 5 now provides a stable libcxx11 ABI, and stable support for C++11 (GCC version before 5 called this supported experimental). This required some changes in the libstdc++ ABI, and now libstdc++6 provides a dual ABI, the classic libcxx98 ABI, and the new libcxx11 (GCC 5 (<< 5.1.1-20) only provides the classic libcxx98 ABI). The bad news is that the (experimental) C++11 support in the classic libcxx98 ABI and the new stable libcxx11 ABIs are not compatible, and upstream doesn't provide an upgrade path except for rebuilding
There is no shortcut.
来源:https://stackoverflow.com/questions/36158934/runtime-error-abicxx11-when-compile-with-g-4-9-on-ubuntu-15-10