views:

241

answers:

3

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?

A: 

I'm sure two libraries can co-exist as long as there are no multiple definition conflicts.

However, I think you can find at least one function signature that didn't change between versions. ;)

So I'm gonna go with no: they will conflict. But this is within the same application.

If you are dynamically (not static) linking with another library, you will not conflict.

GMan
+3  A: 

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

dirkgently
+1  A: 

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

jon hanson