To compile a static library:
For example:
xlc -c bar.c example.c ar -rv libfoo.a bar.o example.o
To compile a shared library:
xlc -c foo.c
xlc -qmkshrobj -o libfoo.so foo.o
You can use the same command string to link a static or shared library to your main program. For example:
xlc -o myprogram main.c -Ldirectory -lfoo
where directory is the path to the directory containing the library.
By using the -l option, you instruct the linker to search in the directory specified via the -L option for libfoo.so; if it is not found, the linker searches for libfoo.a. For additional linkage options, including options that modify the default behavior, see the GCC ld documentation.
Just as you link modules into an application, you can create dependencies between shared libraries by linking them together. For example:
xlc -qmkshrobj -o mylib.so myfile.o -Ldirectory -lfoo