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  -ltest
where directory is the path to the directory containing the library libtest.a.
If your library uses runtime linking, add the -brtl option to the command:
xlc -brtl -o myprogram main.c -Ldirectory -ltest

By using the -l option, you instruct the linker to search in the directory specified via the -L option for libtest.so; if it is not found, the linker searches for libtest.a. For additional linkage options, including options that modify the default behavior, see the AIX® ld documentation (http://publib.boulder.ibm.com/infocenter/aix/v7r1/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds3/ld.htm).