Boost logo

Boost :

Subject: [boost] Suppressing boost.thread and boost.system symbols in shared library
From: Philip Bennefall (philip_at_[hidden])
Date: 2013-08-01 17:30:27


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:

0002abe0 V typeinfo name for
boost::exception_detail::clone_impl<boost::exceptio
n_detail::bad_exception_>
0002ace0 V typeinfo name for boost::exception_detail::bad_exception_
00029920 V typeinfo name for
boost::exception_detail::error_info_injector<boost:
:lock_error>
00029b00 V typeinfo name for
boost::exception_detail::error_info_injector<boost:
:condition_error>
00029860 V typeinfo name for
boost::exception_detail::error_info_injector<boost:
:thread_resource_error>
0002970f V typeinfo name for boost::thread_exception
00029a7b V typeinfo name for boost::thread_interrupted
00029740 V typeinfo name for boost::thread_resource_error
0002ac40 V typeinfo name for
boost::enable_shared_from_this<boost::detail::threa
d_data_base>
0002a720 V typeinfo name for boost::detail::thread_data_base
0002ad20 V typeinfo name for
boost::detail::sp_counted_impl_p<boost::detail::thr
ead_data_base>
0002adc0 V typeinfo name for
boost::detail::sp_counted_impl_p<boost::exception_d
etail::clone_impl<boost::exception_detail::bad_alloc_> >
0002ad60 V typeinfo name for
boost::detail::sp_counted_impl_p<boost::exception_d
etail::clone_impl<boost::exception_detail::bad_exception_> >
000296f1 V typeinfo name for boost::system::system_error

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?

Kind regards,

Philip Bennefall


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