Hi,
I have created a .c
file which is being converted to a .o
file along with around 300 other .c
files and included in a .a
static library. This library, along with many others is being used to create a .so
dynamic library. On analyzing both the .a
and the .so
file with nm
, I found that for some reason the symbols defined in the .c
file are present in the .a
file but not in the .so
file. I can think of no reason this should happen. Can somebody please help me out here? The steps used to create the two binaries are:
gcc -fvisibility=hidden -c foo.c -o foo.c.o
ar cr libbar.a foo.c.o ...
gcc -fvisibility=hidden -fPIC -o libfinal.so libbar.a x.o y.a ...
The reason I have specified visibility hidden here is that I want to expose only a few selected symbols. To expose the symbols from foo.c
I have specified the visibility attribute so that the functions signatures in the header foo.h
look like:
extern int __attribute__ ((visibility ("default"))) func();
EDIT: The command nm libbar.a | grep Ctx
gives:
000023c5 T CtxAcquireBitmap
000026e9 T CtxAcquireArray
00001e77 T CtxCallMethod
However, nm libfinal.so | grep Ctx
does not show anything.
UPDATE: Found another post which discusses the uses of the --whole-archive
option. Also, stumbled across the --export-dynamic
option which apparently tells the linker to retain unreferenced symbols. Investigating further.