osx - Hiding the symbols of a static library in a dynamic library in MAC OS X? -



osx - Hiding the symbols of a static library in a dynamic library in MAC OS X? -

i using static library (eg: boost.a) , *.o files create dynamic library (eg: libdynamic.dylib) in mac os x.

i able hide symbols *.o files since created -fvisibility=hidden flag. but, can't hide symbols boost.a library since have been compiled already.

is there way hide symbols (functions) of static library, in dynamic library ? i.e., if have function (hidden) in myfuncs.o file calls functions(visible) in boost.a file, boost.a functions visible when utilize "nm tool".

please suggest me solution.

first need create sure declare symbols want maintain extern "c" attribute((visibility("default"))) , check "symbols hidden default" in code generation tab of xcode project (i think checked default).

then need create exported symbols file contains symbols want export (keep).

you need point xcode file adding "symbols.exp" "exported symbols file" entry in xcode project linker prefs.

make sure symbols in file start underscore. can create exported symbols file static lib (or raw dylib) using build script:

nm -g $built_products_dir/lib$product_name.dylib | ruby -ne 'if /^[0-9a-f]+.*\s(\s+)$/.match($_) print $1,"\n" end' > symbols.exp

you can command line (replace $built_products_dir/lib$product_name.dylib name of library in case).

this create exported symbols file "symbols.exp" in project directory. can utilize symbols file strip nonessential symbols dylib, so:

strip -u -r -s symbols.exp libxyz.dylib

it might thought set @ end of run script in project well, so:

strip -u -r -s symbols.exp $built_products_dir/lib$product_name.dylib

if utilize script in dylib project create sure add together symbols.exp file project disable (click checkbox next name), xcode can find file.

under xcode 5 strip command complain shown below, though command appears work correctly:

/applications/xcode.app/contents/developer/toolchains/osx10.9.xctoolchain/usr/bin/strip: removing global symbols final linked no longer supported. utilize -exported_symbols_list @ link time when building: /path/to/libyourlib.dylib

as warning states, using -exported_symbols_list alternative (or xcode's exported symbols file setting) allows exactly command symbols exported excluding not in file specify.

osx gcc shared-libraries visibility dylib

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -