Kenwood HP 9000 Personal Computer User Manual


 
Chapter 5 167
Creating and Using Libraries
Caution When Mixing Shared and Archive Libraries
Figure 5-12
$ a.out
/usr/lib/dld.sl: Unresolved symbol: f2 (code) from
/users/steve/dev/lib3.sl
Abort(coredump)
Example 2: Using shl_load(3X)
This example (in 32-bit and 64-bit +compat mode shows how mixing
archive libraries and shared libraries using shl_load(3X) can lead to
unsatisfied symbols and cause a program to abort.
If a library being loaded depends on a definition that does not exist in the
application or any of the dependent shared libraries, the application will
abort with an unsatisfied definition at run time. This seems obvious
enough when an application is first created. However, over time, as the
shared libraries evolve, new symbol imports may be introduced that were
not originally anticipated. This problem can be avoided by ensuring that
shared libraries maintain accurate dependency lists.
Suppose you have a main program, main(), and three functions, f1(),
f2(), and f3() each in a separate source file. main() calls f1() and
uses shl_load() to call f3(). main() does not call f2():
$ cc -c main.c f1.c f2.c Compile to relocatable object code
$ cc -c +z f3.c Compile to position-independent code