building shared libraries

Levi Pearson levi at
Wed Jan 2 08:40:55 MST 2008

Levi Pearson <levi at> writes:

> "Andres Gonzalez" <gonzo at> writes:
>> I am porting a DLL (originally developed for MS Windows) to linux and
>> I have a couple of basic questions about shared libraries in linux.
>> How do you control what symbols and function names are exported or
>> available when building the shared library?
>> My code is compiling fine (using position independent code) and I am
>> producing the .so file. When I run nm on the .so file, it shows tons
>> and tons of symbols. My function names are also mangled. I want to
>> only have a few select API functions available public ally.
> Are you building a C or a C++ library?  If you're using a C++ compiler
> to build a C library, you have to tell it to provide C symbols instead
> of C++ ones.

Oh... regarding visibility of symbols.  The easiest way to restrict the visibility of C symbols is to declare them static, which makes them file-scoped.  If you want to share between files but not export in your shared library, you'll have to delve into deeper magic.  Here's a document that explains everything you need to get started with shared objects:


More information about the PLUG mailing list