|
Home > Archive > Unix Programming > October 2007 > linking against shared libraries
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
linking against shared libraries
|
|
| noident@my-deja.com 2007-10-30, 1:36 am |
| Greetings!
Here's a hopefully simple question:
% cat test.c
#include <openssl/ssl.h>
int main(void)
{
/* just put some stuff here for the linker to link against the
libssl */
SSL_METHOD *meth = SSLv23_client_method();
return EXIT_SUCCESS;
}
% gcc -I /usr/local/ssl/include test.c -L /usr/local/ssl/lib -R /usr/
local/ssl/lib -lssl
% ldd a.out | grep libssl
libssl.so.0.9.8 => /usr/local/ssl/lib/libssl.so.0.9.8
% ls -l /usr/local/ssl/lib/*ssl*
lrwxrwxrwx 1 root root 15 Oct 2 15:38 /usr/local/ssl/
lib/libssl.so -> libssl.so.0.9.8
-r-xr-xr-x 1 bin bin 272264 Mar 20 2007 /usr/local/ssl/
lib/libssl.so.0.9.8
The question is: why does the linker link against libssl.so.0.9.8 and
not against the symlink, which is supposed to be a generic libssl
symlink in case we upgrade libssl? Why is the symlink even there if
it's ignored?
| |
| Paul Pluzhnikov 2007-10-30, 1:36 am |
| noident@my-deja.com writes:
> Here's a hopefully simple question:
The answer is not so simple. To understand what's happening, read
about external library versioning here:
http://docs.sun.com/app/docs/doc/81...mhm7pl20?a=view
> The question is: why does the linker link against libssl.so.0.9.8 and
> not against the symlink...
> Why is the symlink even there if it's ignored?
Who told you it's not "linking against symlink", and that symlink
is ignored?
In fact it *is* using the symlink. You can verify that with
gcc ... -Wl,--verbose # Linux
gcc ... -Wl,-D,files # Solaris
Or remove the symlink, and observe that your link will now fail.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
| |
| noident@my-deja.com 2007-10-30, 7:22 pm |
| OK, that explains it.
I wrongly assumed that the symlink was there for the runtime, but it's
there for the linker to follow at the link time.
Thank you.
|
|
|
|
|