Convert a Static Library to a Shared Library?

Eli Courtwright picture Eli Courtwright · Mar 17, 2009 · Viewed 55.1k times · Source

I have a third-party library which consists mainly of a large number of static (.a) library files. I can compile this into a single .a library file, but I really need it to be a single .so shared library file.

Is there any way to convert a static .a file into a shared .so file? Or more generally is there a good way to combine a huge number of static .a files with a few .o object files into a single .so file?

Answer

dicroce picture dicroce · Mar 17, 2009

Does this (with appropriate -L's of course)

gcc -shared -o megalib.so foo.o bar.o -la_static_lib -lb_static_lib

Not do it?