Originally Posted by raghu_rao
I need to statically link a shared library, so that I may distribute the binary without having to bundle in the lib as well.
I am trying to use the "-static" flag but when I do so the library does not get linked at all.
Am using gcc for linking. Running it on linux 2.6.18-92.el5.
Also, How do I force the linker to pick up the .a instead of the .so?
Any help will be much appreciated.
You can't statically link shared library (or dynamically link static)
Flag -static will force linker to use static library (.a) instead of shared (.so)
But. Static libraries not always installed by default. So if you need static link you have to install static libraries.
Another possible approach is use statifier (http:/statifier.sf.net) or Ermine (http://magicErmine.com
Both tools take as input dynamically linked executable and as output create self-contained executable with all shared libraries embedded.
Statifier is free (licensed under GPL), Ermine is commercial, but it behaves better on systems with memory randomization. Here is theirs comparison: