Posted on 2018-11-28 15:12
Prayer 阅读(243)
评论(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).