How to link with specific library ( g++; libstdc++.so.5 and libstdc++.so.6 )

后端 未结 1 2062
礼貌的吻别
礼貌的吻别 2021-01-06 08:02

A simple question - is there any way to make the g++ linker to link with a specific libstdc++ library version? I didn\'t find anything useful in th

相关标签:
1条回答
  • 2021-01-06 08:38

    Here's the ABI versions table; the default value for the -fabi-version switch changed from 1 to 2 at the same time g++ introduced libstdc++.so.6 with 3.4. This means that to link against the older libstdc++ library you would need to

    • find and use the equivalent C++ headers instead of the ones included with your compiler
    • recompile all your code (and any other C++ libraries you're using) with -fabi-version=1

    otherwise you run the risk of ABI incompatibilities. I can't tell you precisely what the changes were but in general it's best to try and keep all C++ code you have compiled with the same compiler version.

    Assuming you don't want to try and hack things togther like this I think you have two choices:

    1. ask your shared library vendor to recompile the library with your version of GCC for you. This may not be trivial as g++ 3.4 introduced a new stricter C++ parser.
    2. ask your vendor which version of g++ they used to compile the library in the first place and use that version to compile your own code. RH might provide a compat-gcc compiler as well as the libstdc++ - I can't remember. However you'll also need down-level versions of all other libraries and OS-provided C++ libraries that you're using, so might be easiest to compile on a VM with an older Red Hat version that had the right compiler.
    0 讨论(0)
提交回复
热议问题