hi , i have a static library libsrp.a, i want to make a shared library libsrp.so from it that contains all symbols . please tell me how to make a .so under ubuntu.
thanks
hi , i have a static library libsrp.a, i want to make a shared library libsrp.so from it that contains all symbols . please tell me how to make a .so under ubuntu.
thanks
Recompile the object files contained in libsrp.a with the flag to create position independent code (fpic) as in
gcc -fpic -c foo.c
gcc -fpic -c bar.c
Now you can combine foo.o and bar.o into a shared library as in
gcc -shared -o libshared.so foo.o bar.o
Use the --whole-archive
flag:
gcc -shared -o libsrp.so -Wl,--whole-archive -lsrp -Wl,--no-whole-archive
From the ld man page (my emphasis):
--whole-archive For each archive mentioned on the command line after the --whole-archive option, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library. This option may be used more than once.