Prayer

在一般中寻求卓越
posts - 1256, comments - 190, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Linking a library to an application

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


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理