Can g++5.4 link library compiled by gcc4.8 safely?

leo chen izhiqiu.chen@gmail.com
Thu Nov 14 03:58:00 GMT 2019


Dear developers,

I have got a problem about g++ compatibility.

I want to compile a c++ program by g++5.4, which need to link a library
compiled by g++4.8. I noticed the dual_abi
<https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html> since
g++5.1, so I set -D_GLIBCXX_USE_CXX11_ABI=0 in my CMakeLists.txt. The
compilation is ok but I got segmentation fault when I run the program.
To make it clear, the program works well when I downgrade my compiler to
g++4.8.
I wonder if there is any way we can link old library compiled by g++4.8
without downgrade high version g++ compiler (g++5.1 above) ?

Any suggestions and response would be appreciated!.

Thank you!
izhiqiu chen



More information about the Gcc-help mailing list