This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Mixing libstdc++.6 and libstdc++.5 in the same application
- From: Ian Lance Taylor <iant at google dot com>
- To: Magnus SjÃgren <magnus dot sjogren at comsol dot se>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: 12 Feb 2008 11:55:22 -0800
- Subject: Re: Mixing libstdc++.6 and libstdc++.5 in the same application
- References: <47B19F72.4020209@comsol.se>
Magnus SjÃgren <magnus.sjogren@comsol.se> writes:
> I am developing an application in C++ with a GCC version that uses
> libstdc++.6 and wants to link to a dynamic library which has a pure C
> API, but internally uses C++ and depends on libstdc++.5.
>
> Are there any problems doing this?
You didn't say what system you are using. I'm going to assume
GNU/Linux or some other ELF system.
Yes, there are problems. It mostly works, and it may work in your
case. But there are some cases where the same symbol name is used in
both libstdc++.so.5 and libstdc++.so.6, and the dynamic linker will
let one library override the other in using that symbol name. If
those symbols are used by your program, you will have trouble.
There are some relatively baroque ways to get around this. For
example, you can use the linker's -F/--filter option to create a new
dynamic library which defines only the symbols exported by the C API.
That should hide the libstdc++.so.5 symbols from the dynamic linker,
and prevent the overriding confusion. But I haven't actually tried
this, and I can't promise that it will work.
Ian