Chapter 5 187
Creating and Using Libraries
Using Shared Libraries in 64-bit mode
Library Example: Creating a 64-bit Standard Mode
Shared Library
The following example builds a standard mode library.
ld -b file1.o -o libfile1.sl +h libfile1.1
ld -b file2.o -o libfile2.sl +h ./libfile2.1
ld -b file3.o -o libfile3.sl +h /var/tmp/libfile3.1
ld -b file4.o -o libfile4.sl
ld -b file3a.o -o libfile3a.sl -L. -lfile1 -lfile3 +h libfile3a.1
ld -b file2a.o -o libfile2a.sl libfile2.sl ./libfile4.sl +b
/var/tmp
elfdump -L libfile3a.sl libfile2a.sl
libfile3a.sl:
*** Dynamic Section ***
Index Tag Value/Ptr
0 Needed libfile1.1
subject to dynamic path lookup
1 Needed /var/tmp/libfile3.1 not subject to dynamic path
lookup--internal pathname has a “/”
2 Soname libfile3a.1
3 Rpath .
...
libfile2a.sl:
*** Dynamic Section ***
Index Tag Value/Ptr
0 Needed ./libfile2.1
not subject to dynamic path lookup
1 Needed ./libfile4.sl not subject to dynamic path lookup
2 Rpath /var/tmp
...
The dynamic loader does dynamic path searching for libfile1.sl.. It
does not do dynamic path searching for libfile2.sl, libfile3.sl,
and libfile4.sl.
Library example: 64-bit Mode Dynamic Path
Searching
This example of dynamic path searching demonstrates differences
between compatibility mode and standard mode dependent shared
libraries. The example builds standard mode libraries and does a
standard mode link. By default, the dynamic loader looks at the
environment variables LD_LIBRARY_PATH and SHLIB_PATH to find the
shared libraries.
# build standard mode shared libraries
#libfile1.sl is a dependent of libfile2.sl