[SATLUG] Creating a binary.....

Bruce Dubbs bruce.dubbs at gmail.com
Tue Mar 6 14:10:16 CST 2012

Enrique Sanchez wrote:
> I have a little C program that I want to use across different environments
> and I am trying to find a "smart" (aka lazy) way to be able to use it
> without having to recompile it for every single version of a particular
> library found in the environment.
> so far, I have the object files of all programs involved just need to
> perform the final linking phase of them all but so far I haven't been very
> successful getting it to work...
> here is the inventory...
> [user at server 64bit]> ls -la
> total 32
> drwxr-xr-x 2 user user  4096 Mar  5 09:57 .
> drwxr-xr-x 3 user user  4096 Mar  5 09:56 ..
> -rw-r--r-- 1 user user  6344 Mar  3 22:22 keymgrd.o
> -rw-r--r-- 1 user user 16368 Mar  3 22:22 km_utils.o
> currently I get my binary using this command:
> [user at server 64bit]>  gcc -v -lcrypto -lssl -o keymgrd  km_utils.o keymgrd.o
> but I would like to get to a level where I could use just the linker
> because I don't have GCC installed everywhere and I would like just to
> relink the software every time I upgrade the OpenSSL library files,

You don't understand what a dynamic library is.  The -lcrypto and -lssl 
switches say to link with the appropriate library

lrwxrwxrwx      18 Oct 14 /usr/lib/libcrypto.so -> libcrypto.so.1.0.0
-r-xr-xr-x 2015595 Oct 14 /usr/lib/libcrypto.so.1.0.0
lrwxrwxrwx      15 Oct 14 /usr/lib/libssl.so -> libssl.so.1.0.0
-r-xr-xr-x  415747 Oct 14 /usr/lib/libssl.so.1.0.0

To link into a new version, you just change the library and the loader 
does the rest.  You do not have to relink the application.

If you have both a .so and a .a library, the liker uses the .so dynamic 
library by default.

   -- Bruce

More information about the SATLUG mailing list