Compiling a shared library

To compile a shared library:

  1. Compile your source files into an object file, with no linking. Note that in the case of compiling a shared library, the -qpic compiler option is also used. For example:
    xlc -qpic -c foo.c
  2. Use the -qmkshrobj compiler option to create a shared object from the generated object files. For example:
    xlc -qmkshrobj -o libfoo.so foo.o