help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Link to static library from DSO without exporting symbols?


From: Boris
Subject: Re: Link to static library from DSO without exporting symbols?
Date: Fri, 29 Sep 2006 00:10:00 +0300

Paul Pluzhnikov wrote:
> "Boris" <boris@gtemail.net> writes:
>
> [...]
>> When I link the Expat XML parser though the DSO
>> exports all symbols of the Expat XML parser. Is there any option to
>> tell g++ or the linker not to do this?
>
> Assuming Linux, the answer is to use linker version script and
> explicitly make only your "public" interface visible, hiding
> everything else.

Why is this so complicated? If I build a shared library like this:

g++ -shared -o libfoo.so foo.o -lbar

why doesn't the linker (I'm on Linux) hides automatically all the symbols 
from libbar? Isn't it safe to assume that libfoo probably wants to get 
linked to some symbols in libbar but does not want to export these symbols? 
In my example where I link a shared library to the Expat XML parser I want 
to make use of some functions from Expat and not create a shared library 
which among others provides the same functions as Expat does already. What's 
the rationale of exporting all symbols by default?

Boris 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]