Chapter 5 169
Creating and Using Libraries
Caution When Mixing Shared and Archive Libraries
Figure 5-15
When you run a.out, it runs correctly. Now suppose you need to modify
f3() to call f2():
Figure 5-16
Problem
Here is where a problem can be introduced. If you compile the new f3()
and rebuild the shared library lib3.sl without specifying the
dependency on a shared library containing f2(), calls to f3() will abort.
$ cc -c +z f3.c Compile to position-independent code.
$ ld -b -o lib3.sl f3.o Error! Missing library containing f2().