On 04/28/2011 09:57 AM, Steve Jaffe wrote:
To be specific: I have two versions of libssl in /lib: libssl.so.4 and
libssl.so.6. What happens is that the .so.4 version is always linked --
what determines this behavior? (and how could one therefore change it, ie
specify which version to choose?)
Here's what happens: Notice I'm doing nothing but linking libssl to an empty
library so there are no other dependencies that could affect the result.
g++ foo.so -shared -lssl
ldd foo.so |grep ssl
libssl.so.4 => /lib/libssl.so.4 (0xf7f04000)
The dynamic linker user the contents of the DYNAMIC program header to
control its actions.
The NEEDED tags contains a list of libraries that are needed.
You can view these with the readelf program:
$ readelf -d /bin/ls
Dynamic section at offset 0x18a88 contains 28 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [librt.so.1]
0x0000000000000001 (NEEDED) Shared library: [libselinux.so.1]
0x0000000000000001 (NEEDED) Shared library: [libcap.so.2]
0x0000000000000001 (NEEDED) Shared library: [libacl.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x402040
0x000000000000000d (FINI) 0x411c88
.
.
.
Really the only sane way to change the libraries is to re-link your
program (with /usr/bin/ld or gcc) against the desired libraries.
David Daney