3

I have an old application framework that must be compiled with gcc 4.4.4 and an old libstdc++.so, which don't support C++14.

I want to use gcc 6.2 to write my new functions in C++14, and compiled them into a static library myslib.a.

myslib.a exports its functions only in pure C interfaces for ABI compatibility.

My issue is: The framework uses an old libstdc++.so, which is not compatible with C++14.

Is it possible to enforce myslib.a to statically link the latest libstdc++.a and ignore the older libstdc++.so?

Torbjörn
  • 5,512
  • 7
  • 46
  • 73
xmllmx
  • 39,765
  • 26
  • 162
  • 323
  • I don't think that can be done for a static library. Why don't you make it an so? – Leon Aug 29 '16 at 06:47
  • 1
    "must be compiled with gcc 4.4.4": why? More to the point, libstdc++.so.6 is backwards compatible, so you can just use the more recent one. – Marc Glisse Aug 29 '16 at 06:47
  • Have you tried compiling it with gcc-6? Have you tried compiling it with gcc-4.4, but linking with gcc-6? What were the errors in these cases? – Jan Hudec Aug 29 '16 at 06:51
  • @Leon, it is acceptable to use so – xmllmx Aug 29 '16 at 07:01
  • @Leon, ELF goes to great lengths to make static and dynamic libraries behave the same way. Making .so use each its own runtime requires a lot of black magic on ELF systems (unlike DLL systems where they just do that and care must be taken if you want them to use the same one). – Jan Hudec Aug 29 '16 at 07:04
  • @MarcGlisse, the framework has already many shared libraries compiled with an older libstdc++.so. – xmllmx Aug 29 '16 at 07:05
  • 1
    To answer the question in the title, no. You shoud be able to compile and/or link the old framework with the new libstd++.so though. – n. m. could be an AI Aug 29 '16 at 07:10
  • Why not just compile all stuf with new gcc, and use different `-std=c++VERSION` for different files, like `-std=c++03` for old stuff, and `-std=c++14` for new one. – fghj Aug 29 '16 at 08:33
  • @user1034749, the framework must use som COMPILED libraries, so I cannot rebuild all with gcc 6.2. – xmllmx Aug 29 '16 at 08:45
  • Again: libstdc++.so.6 is backwards compatible. You can compile with gcc 4.4.4, then replace the libstdc++.so.6 with a new version, and the program will still run just fine. – Marc Glisse Aug 29 '16 at 10:38
  • @MarcGlisse You are probably right. I have read that the ABI has changed with GCC 5.1, but they now have both the new and old implementations in different namespaces in the same lib, so this should work. If you still have problems you can maybe use a C-wrapper-library which statically links your other libstdc++.a version, as in [this post](https://stackoverflow.com/questions/1655310/how-to-build-an-application-that-requires-both-libstdc-so-5-and-libstdc-so-6) – karsten Jun 01 '18 at 15:04

0 Answers0