问题
Can an application depend on two different versions of libstdc++ at the same time? (e.g.: libstdc++5 and libstdc++6)? The scenario being - some binary depends on libstdc++ 6 but loads an .so that depends on libstdc++5...
Will that have any chance of working?
回答1:
Most importantly, you need to check if those two versions of the library are binary compatible or not. G++ 3.3 and 3.4 are not, for example.
And even if they are: * There can be name mangling issues * You cannot do cross module allocation/deallocation (a bad idea anyway) * You probably can't work around modules with STL
回答2:
I just recently ported a C++ application from AS3/GCC323 to AS4/GCC346. Although the app itself linked to libstdc++.so.6 some of the libraries it linked to were still linking to libstdc++.so.5. Depsite building successfully it SEGV'ed when i tried to run it.
Once I recompiled the libraries on AS4/GCC346 as well, the app and the libraries only linked to libstdc++.so.6 and the SEGV's no longer occurred.
So i would say the answer is no you can't link to both.
Jon
来源:https://stackoverflow.com/questions/728858/can-an-application-depend-on-two-different-versions-of-libstdc