免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1221 | 回复: 1
打印 上一主题 下一主题

Tru64下如何编译使和用自己的动态链接库 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-07-28 15:07 |只看该作者 |倒序浏览
网上又很多编译动态链接库的文章,但是几乎没有Tru64unix下的自己查看了下帮助,总结出来和大家共享。


环境: alpha ds10, Tru64 unix5.1b,  cc 编译器

首先要有一个源文件如wbc.c

1:用如下命令语句创建一个目标文件
cc -c  wbc.c
得到wbc.o

2:用如下命令连接成动态连接库文件
ld -shared -expect_unresolved '*' -o libwbc.so wbc.o
得到一个动态连接库libwbc.so,
可以使用ldd libwbc.so 和 nm  libwbc.so命令查看里边内容

3:main.c使用此动态连接库的方法如下:
cc -o main.exe libwbc.so main.c
得到可执行文件main.exe

我试验,《unix环境高级编程》上的例程都是上面的方法。

论坛徽章:
0
2 [报告]
发表于 2004-07-28 15:09 |只看该作者

Tru64下如何编译使和用自己的动态链接库

参数的作用如下
//在man ld中
-error_unresolved
      Produce an error message and return a nonzero error status when
      unresolved symbols are encountered, except for those matching
      -expect_unresolved. This is the default behavior for linking executable
      programs.
#当遇到不明符号时产生error message and return a nonzero error status,是默认参数


-update_registry location_file
      Register the location of this shared object's segments and make sure
      they stay out of the way of others in the location_file. The
      location_file is updated if it is writable. This option is used with
      -shared.
#将加产生的so_locations,定位为location_file

You use the following switches to alter the manner in which ld searches
  -lx Search a library, libx.{so|a}, where x is a string.

-noarchive
      Require -l references to resolve to shared objects. Normally, if the
      shared object as specified by the -l is not found, the linker attempts
      to find the corresponding archive to resolve undefined symbols. This
      option disallows using those archives. Note that this option is posi-
      tion sensitive and can be used more than once on a command line. It
      affects only those options that follow it, and it is turned off by the
      next occurrence of a -noso or -so_archive option.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP