Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ -fvisibility=hidden -fvisibility-inlines-hidden

I have a question about the C++ visibility attribute. I have read http://gcc.gnu.org/wiki/Visibility and yet I dont quite understand how it works.

I want use the visibility to be hidden on some of my shared libraries I have. I believe this means that the symbols are hidden ?

How are you meant to link the shared library then ? Is there a special way ? If I link it how it normally gets linked it doesnt work.

Can someone help me please.

like image 890
nixgadget Avatar asked Aug 25 '10 21:08

nixgadget


Video Answer


1 Answers

-fvisibility=hidden makes all your symbols hidden by default.

What you then have to do, is choose which functions you want to be visible to users linking against your library and make them visible by marking them with a visible attribute.

E.g.

void __attribute__((visibility("default"))) Exported() {     // ... } 
like image 67
CB Bailey Avatar answered Sep 29 '22 11:09

CB Bailey