Linking a library to an application

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.
If your library uses runtime linking, add the -brtl option to the command:
xlc -brtl -o myprogram main.c -Ldirectory -lfoo

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 AIX® ld documentation.