Let me explain the scenario. We have an obsolete C ++ compiled .so library. Functions in this library are declared using extern "c" {}, so the library can be used with both C and C ++ programs, plus, for some reason, it was created with an option --static-libgcc.
This old library is very old and difficult to maintain. Now we managed to write it, but in C. Let's say the old library is called libfoo.so (old), and the new one is libfoo.so (new). For a given bar.o, it can be associated with either the old or the new libfoo.so to create an executable file, say, bar.exe. But bar.exe can only work with the same .so library with which it was previously linked, in other words, these two libraries are not interchangeable.
EDIT # 1 . I made a symbolic link named libfoo.so to point to libfoo.so (old) or libfoo.so (new). This symbolic link libfoo.so is located at LD_LIBRARY_PATH at run time.
EDIT # 2 . When I linked bar.o to the old libfoo.so and the generated bar.exe, if I ran this bar.exe with the new libfoo.so, it reported an error undefined symbols. In nmthese two libfoo.so, I can recognize these characters in the old, but not in the new. Symbols is something like _ZSt4cerr, which is the changed C ++ lib name (although it was brought --static-libgcc), and of course the new libfoo.so does not contain these symbols.
EDIT # 3 . If I just compile and link C code with g ++ instead of gcc, does that make sense?
How to implement this?
EDIT # 4. / C- libfoo g++ ( libgcc, static libstd++), ++, libfoo. . , , .