Posted on 2018-11-28 15:12
Prayer 閱讀(271)
評論(0) 編輯 收藏 引用 所屬分類:
LINUX/UNIX/AIX
https://www.ibm.com/support/knowledgecenter/SSGH2K_12.1.0/com.ibm.xlc121.aix.doc/proguide/link_app.html#link_app
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.
先找靜態庫,再找動態庫。如果找不到so,則找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).