Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automake+libtool+c++ = very bloated interface

First i have "include_HEADERS = 'my public headers'" and "libfoobar_la_SOURCES = 'private sources' 'private headers'". All is fine. It compile/install/link. But when i do "nm -C my_instaed_lib.so" i get:

00005be0 T yyget_debug(void*)
00005b00 T yyget_extra(void*)
00005bf0 T yyset_debug(int, void*)
00005bb0 T yyset_extra(FM4::LexImpl*, void*)
00005b40 T yyget_column(void*)
00005b10 T yyget_lineno(void*)
00006180 T yyset_column(int, void*)
000061e0 T yyset_lineno(int, void*)
...

This never declared in any header.

000091f0 T FM4::PrcImpl::CollectMacro()
000089d0 T FM4::PrcImpl::CollectQuote()
00008870 T FM4::PrcImpl::CollectComment()
00009350 T FM4::PrcImpl::Collect()
000093f0 T FM4::PrcImpl::Process()
00008700 T FM4::PrcImpl::PrcImpl(FM4::Processor*)
00008590 T FM4::PrcImpl::PrcImpl(FM4::Processor*)
00009970 W FM4::PrcImpl::~PrcImpl()
00009a00 W FM4::PrcImpl::~PrcImpl()
...

This in private not installed header.

I read automake/libtool manual twice, but i don't know how strip this crap from interface? Or what can expose this crap to public api. How control what exported to public api?

like image 325
SQLek Avatar asked Feb 13 '11 00:02

SQLek


2 Answers

Look for the libtool option -export-symbols. Give it a list of symbols that you want to export. By default, libtool exports all symbols.

like image 78
Peter Eisentraut Avatar answered Sep 28 '22 07:09

Peter Eisentraut


If you're adventurous, and can be sure that you're compiling with a new enough GCC (I think ≥4.2 is necessary for good support), visibility can help.

Restrict the default visibility (-fvisibility=hidden) and explicitly mark the functions you want to export with __attribute__((visibility("default"))).

like image 24
ephemient Avatar answered Sep 28 '22 09:09

ephemient