LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   static and dynamic linking (https://www.linuxquestions.org/questions/programming-9/static-and-dynamic-linking-721924/)

zb10948 04-27-2009 02:02 AM

static and dynamic linking
 
Hello,

is it possible, with GNU toolchain, to statically relink dynamically linked binary? For instance, if i have a.out that depends on libsomething, i want to integrate libsomething into a.out.

Hko 04-27-2009 03:48 AM

Yes, but you will need:
  • the source code for the program (to be precise: actually the object file).
  • The static version of the lib. If you have the source, you can probably recompile the lib to static version (*.a type of lib file instead of *.so).
  • Relink the object file of the program with the static lib

But, are you sure you need to do this? If there is an update for the (shared version) of the lib, your program will still use the old version until it gets re-linked with the new version of the static lib. Also using static libs isless memory efficient.


All times are GMT -5. The time now is 12:37 AM.