Figure 13 Example 1: Unsatisfied Symbols: Mixing Shared and Archive Libraries

Now link the main with the libraries, and create the executable a.out:

$ cc main.o lib12.a lib3.so

Link the program .

Figure 14 Example 1: Unsatisfied Symbols: Creating the Executable

When you run a.out, it runs correctly. Now, suppose you need to modify f3() to call f2():

Figure 15 Example 1: Unsatisfied Symbols: Modifying a Function

Compile the new f3() and rebuild the shared library lib3.so:

$ cc

-c

+z

f3.c

Compile

to relocatable code.

$ ld

-b

-o

lib3.so f3.o

Create

a new shared library

Figure 16 Example 1: Unsatisfied Symbols: Rebuilding the Shared Library

Problem

Here is where the problem can occur. If you do not relink the application, main.o, and just run a.out with the new version of lib3.so, the program aborts because f2() is not available in the application. The reference to f2() from f3() remains unsatisfied, producing an error in PA-32 mode:

Caution When Mixing Shared and Archive Libraries 119