Re: libstdc++ compatibility frustrations under linux x86



Henrik Goldman wrote:

Assume you have a static library LIB written in C++ that exports a C interface like LIB_init(), LIB_action() and LIB_free(). Internally this LIB is in C++ but from outsiders it must from C.

I think you might need to rephrase the last sentence.

LIB is depending on STL and therefore depends on libstdc++. We cannot have dynamic linking with libstdc++ since it causes compatibility problems if LIB is used with a different compiler version for linking. libstdc++ only guarranties binary compatibility between minor versions. To overcome this we do static re-linking of the symbols into our library.

This relinking is done like:
ld -r $TMP/to_be_fixed.$O `$CXX --print-file-name=libstdc++.a` `$CXX --print-file-name=libgcc_eh.a` -o $filename;

This will merge the libstdc++ symbols into our library... which is good. Afterwards we need to hide them and we wrote a simple tool that works together with objcopy. objcopy does the job of hiding the symbols... but we furthermore change the section names to avoid same names between our library and other code.

So now we have a another user who is using LIB into his application APP (also c++ application).
This APP is compiled with an older g++ compiler more specifically g++ 3.3.6.
However for now he wants that his users should be able to use his application on older linux.

He is therefore sending his libstdc++.so.* and libgcc.so* to the end-users...

Now hell breaks loose though... since the library LIB starts to act weird and not as documented. This has caused a number of days of work only to realise what the problem is.

So LIB is suppose to use it's own private copy of libstdc++ instead of the public one... however I'm not sure about the legality of sending out libstdc++ libraries to other machines.
I said for now that the user should try to link the application statically so they won't have a shared copy.

I'm unsure about this whole scenario. There is very little and sparse documentation on this on the internet... this doesn't help in actually finding out which of these steps are legal and which should be avoided.

Can anyone shed some light on this complex issue?

Paul Pluzhnikov is one of the linker guruz :-)
You might find him in the gnu.gcc.help newsgroup.

Regards.
.



Relevant Pages

  • libstdc++ compatibility frustrations under linux x86
    ... Assume you have a static library LIB written in C++ that exports a C ... LIB is depending on STL and therefore depends on libstdc++. ... libstdc++ libraries to other machines. ... documentation on this on the internet... ...
    (comp.unix.programmer)
  • Re: g++: Getting a small libstdc++
    ... involve finding all symbols needed from libstdc++ and creating a lib ... including this minimum set of functions. ... Linking against these libraries instead of libstdc++ one can reduce the binary size and storage space for libraries considerably! ...
    (comp.os.linux.embedded)
  • Re: g++: Getting a small libstdc++
    ... how to create a tailor-made libstdc++.so. ... involve finding all symbols needed from libstdc++ and creating a lib ... including this minimum set of functions. ...
    (comp.os.linux.embedded)
  • Re: Getting started on the HP49g+
    ... either the original HP extable lib ... extable2 lib from http://www.hpcalc.org/details.php?id=3940. ... ask again if you have any problem installing libraries. ... compile the string with ASM (listed in the development lib menu, ...
    (comp.sys.hp48)
  • Re: How to "import" an interface into a module w/o `include?
    ... libs but not one file per lib. ... do you mean that you have used 'vlog' to compile your source files ... into ModelSim libraries of those names? ... could possibly know it's an interface). ...
    (comp.lang.verilog)