Boost logo

Boost :

Subject: Re: [boost] Suppressing boost.thread and boost.system symbols in shared library
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-08-01 17:45:38


On Thursday 01 August 2013 23:30:27 Philip Bennefall wrote:
> Hi all,
>
> I am building a shared library for Linux, for which I would like to export
> as few symbols as possible (ideally only the functions that my library users
> actually need to call). When building my project, I have the following
> options:
>
> -fvisibility=hidden -fvisibility-inlines-hidden
>
> I then mark all the functions that I am exporting as having default
> visibility. I link to static versions of boost.thread and boost.system. When
> I then say:
>
> nm -DC libtest.so
>
> I get a large number of symbols such as:
>
> I see this after having stripped the binary. Is there any way to get rid of
> these? Do I need to build Boost with some special cxxflags?

You can pass compiler arguments in the cxxflags=... argument for bjam but that
won't help much because you'll likely want to export RTTI symbols.

You can apply a map file when linking your library (google for -Wl,--version-
script=... argument). The map file should make all RTTI and your symbols
public while hiding everything else. From my experience this approach is the
most flexible. Note that you can still mark some of your functions as
private/public by applying visibility attributes - the map file will only hide
symbols that were left public by the compiler.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk