4

If all I have of a library is a *.a static library. Is there a way I can convert that to *.so dynamically linked library? Maybe using ld?

I'm using SUSE Linux. ELF platform.

harschware
  • 12,277
  • 17
  • 52
  • 85
  • See also http://stackoverflow.com/questions/2649735/how-to-link-static-library-into-dynamic-library-in-gcc. – dubiousjim Dec 29 '11 at 12:31

1 Answers1

7

This command will attempt to do what you want:

gcc -shared -Wl,--whole-archive library.a -o library.so

But if your library wasn't compiled with -fpic/-fPIC, which it probably wasn't, it won't work (it might appear to work, but you don't get any of the benefits of shared libraries).

zwol
  • 129,170
  • 35
  • 235
  • 347