libstdc++ compatibility frustrations under linux x86
- From: "Henrik Goldman" <henrik_goldman@xxxxxxxxxxxx>
- Date: Sat, 24 Nov 2007 13:47:28 +0100
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.
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?
Thanks.
-- Henrik
.
- Follow-Ups:
- Re: libstdc++ compatibility frustrations under linux x86
- From: Paul Pluzhnikov
- Re: libstdc++ compatibility frustrations under linux x86
- From: Spoon
- Re: libstdc++ compatibility frustrations under linux x86
- Prev by Date: Re: Socket programming: Command and Data socket
- Next by Date: Re: which glibc my "self extractable"/ binary is using?
- Previous by thread: Socket programming: Command and Data socket
- Next by thread: Re: libstdc++ compatibility frustrations under linux x86
- Index(es):
Relevant Pages
|
|