Originally Posted by Matir
I believe you'd need to use:
gcc -shared -Wl,-soname,LIBNAME -o LIBNAME OBJFILES -lOTHERLIBRARY
I'm trying to build a .so from a .a like so:
ar r foo.a foo.o
gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 foo.a
A .so is produced but linking against it results in undefined references to globals in foo.o. However just using the .o ...
gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 foo.o
works fine and all global symbols in foo.o are found.
What do I need to do to get the linux linker to see globals in foo.a? I tried a version script but either I got it wrong or I'm missing something.
Ultimately I have two goals:
1) produce a .so from a .a
2) control which symbols are visible (i.e. global) in the .so
FWIW, I'm coming from an AIX background where .a's work in this context and symbol visibilty can be controlled via .exp files.
Any help would greatly be appreciated.