Linker option on linux to load all symbols

jamie_lynn used Ask the Experts™

When creating a shared library, what is the linker option to add all the symbols?
I tried --export-dynamic but it didn't work for me..
I am using linux  2.6.5

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Assuming you use gcc for linking, that should be :


which passes the --export-dynamic option along to the linker.


It isn't working for me..

So i am building one shared libray from 3 static libraries.
i.e. Building from a.a, b.a, c.a,  and xxx.c
The missing symbols are from the static library.  If a use the symbol in xxx.c, then of course the shared library has that symbol.  If i don't use it, then it is missing.

I tried -Wl,-export-dynamic and -rdynamic when building, but didn't work

Someone told me to include a symbol file... Is that true?
Top Expert 2009

Can you post the exact commands you use to build the shared library ?
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples


gcc -shared -static-libgcc -Wl,-export-dynamic -L/space/openldap/linux86w -L/space/libcommonssl/linux86w -o xxx.o /space/libs/a.a /space/libs/b.a /space/libs/c.a -commonssl2 -rdynamic
I found the answer. You have to use --whole-archive

First, gcc doesn't know about this option, so you have to use -Wl,-whole-archive. Second, don't forget to use -Wl,-no-whole-archive after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well.


The whole-archive option included all the symbols.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial