...

libfile2a.so:

*** Dynamic Section ***

Index

Tag

Value

0

HPNeeded

0:/home/knish/./libfile2.1

1

HPNeeded

0:./libfile4.so

2Rpath /var/tmp

...

Library Example: Creating an IPF Standard Mode Shared Library

The following example builds a standard mode library:

$ ld -b file1.o -o libfile1.so +h libfile1.1

$ ld -b file2.o -o libfile2.so +h ./libfile2.1

$ ld -b file3.o -o libfile3.so +h /var/tmp/libfile3.1 $ ld -b file4.o -o libfile4.so

$ ld -b file3a.o -o libfile3a.so -L. -lfile1 -lfile3 +h libfile3a.1

$ ld -b file2a.o -o libfile2a.so libfile2.so ./libfile4.so +b /var/tmp $ elfdump -L libfile3a.so libfile2a.so

libfile3a.so:

*** Dynamic Section ***

Index Tag Value/Ptr

0Needed libfile1.1

1Needed /var/tmp/libfile3.1

2Soname libfile3a.1

3Rpath .

...

libfile2a.so:

*** Dynamic Section ***

Index Tag

Value/Ptr0

Needed ./libfile2.1

1Needed ./libfile4.so

2Rpath /var/tmp

...

The dynamic loader does dynamic path searching for libfile1.so. It does not do dynamic path searching for libfile2.so, libfile3.so, and libfile4.so.

Library example: IPF 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.so is a dependent of libfile2.so $ ld -b file1.o -o libfile1.so +h libfile1.1

$ ld -b file2.o -o libfile2.so +h libfile2.1 -L. -lfile1 $ ld main.o -L. -lfile2 -lc

#move dependent lib so dld can't find it

#dld won't find library because we didn't set the environment

#variable LD_LIBRARY_PATH and SHLIB_PATH

#By default, dld will look at the environment variables

#LD_LIBRARY_PATH and

#SHLIB_PATH when doing dynamic path searching unless +noenvvar

#is specified

$ mv libfile2.so /var/tmp

$ ln -s /var/tmp/libfile2.so /var/tmp/libfile2.1

132 Creating and Using Libraries

Page 132
Image 132
HP UX Software Transition Kit (STK) manual Library example IPF Dynamic Path Searching