Shared library linking to Static library
Andrew Haley
aph@redhat.com
Tue Apr 14 13:02:00 GMT 2009
Roopa V wrote:
> I have an application which links to two libraries, a static library,
> “libstatic.a” and a dynamic library, “libdynamic.so”. The shared
> object “libdynamic.so” also internally links to “libstatic.a”. A
> global variable is defined in libstatic.a and is accessed in both test
> application and libdynamic.so. I'm exporting required symbols of
> libdynamic.so to the application using libdynamic.map file with
> --version-scripts linker option. libdynamic.map file is defined as:
> {
> global:
> operation_*;
> local:
> *;
> };
>
> This creates two copies of libstatic in the memory. libdynamic shared
> object uses its own "private copy" of libstatic.
That's very odd. Are you sure that everyone exports the global variable?
As long as they do, the dynamic linker should fix everything to point to
the same variable.
Andrew.
More information about the Gcc-help
mailing list