免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: wooin
打印 上一主题 下一主题

可以把多个.a文件打包进一个.a文件中吗? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2009-12-22 12:11 |只看该作者

回复 #10 wxfjx 的帖子

Usage: /usr/libexec/elf/ar [-X32_64] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...
       /usr/libexec/elf/ar -M [<mri-script]
commands:
  d            - delete file(s) from the archive
  m[ab]        - move file(s) in the archive
  p            - print file(s) found in the archive
  q[f]         - quick append file(s) to the archive
  r[ab][f][u]  - replace existing or insert new file(s) into the archive
  t            - display contents of archive
  x[o]         - extract file(s) from the archive
command specific modifiers:
  [a]          - put file(s) after [member-name]
  [b]          - put file(s) before [member-name] (same as [i])
  [N]          - use instance [count] of name
  [f]          - truncate inserted file names
  [P]          - use full path names when matching
  [o]          - preserve original dates
  [u]          - only replace files that are newer than current archive contents
generic modifiers:
  [c]          - do not warn if the library had to be created
  [s]          - create an archive index (cf. ranlib)
  [S]          - do not build a symbol table
  [v]          - be verbose
  [V]          - display the version number
  [-X32_64]    - (ignored)
/usr/libexec/elf/ar: supported targets: elf32-i386 srec symbolsrec tekhex binary ihex

很明显,x 命令是用来解包的,这和 tar 一样。tar 只不过是 tape archive 的意思而已嘛 :wink:

$ ar x archive.a

论坛徽章:
0
12 [报告]
发表于 2009-12-22 12:34 |只看该作者
  遇问题先man 有加就有解

论坛徽章:
0
13 [报告]
发表于 2009-12-22 13:45 |只看该作者
谢谢斑竹,
马上就试试看,应该能成功了:wink:

论坛徽章:
0
14 [报告]
发表于 2009-12-22 13:47 |只看该作者
原帖由 pagx 于 2009-12-22 11:38 发表
ar a libxxx.a killboss.o
randlib libxxx.a

这样可以不?

顶楼已经说得很清楚了呀。

论坛徽章:
0
15 [报告]
发表于 2009-12-22 13:50 |只看该作者
原帖由 langue 于 2009-12-22 12:00 发表
.a 只是 Unix archive,可以存储任何文件,你用 ar 打包进去的不是 .o,而是 .a。
正确的做法是先解包,再重新打包成单一的 archive。


版主的意思是不是说多个.a文件打包成的.a文件不能当成正常的.a文件使用,

而是要将多个.a文件分别解包成更多个.o文件,再将这些.o文件打包成一个.a文件?

论坛徽章:
0
16 [报告]
发表于 2009-12-22 14:07 |只看该作者
楼上正解,刚试了下,就是这样的,呵呵,谢谢斑竹

论坛徽章:
0
17 [报告]
发表于 2010-03-02 14:20 |只看该作者
可以的。直接将.a文件打包成.a件是不可以的。即使生成了.a文件也是不正确的。请参考本人写的一篇文章,正是将多个.a(一般是子目录库文件)打包成一个大的.a文件。

linux ar 打包库到另一个库中
http://hi.baidu.com/20065562/blo ... bf73084c088db7.html

答案来自:『20065562's Blog』 有水的地方就有余

论坛徽章:
15
射手座
日期:2014-11-29 19:22:4915-16赛季CBA联赛之青岛
日期:2017-11-17 13:20:09黑曼巴
日期:2017-07-13 19:13:4715-16赛季CBA联赛之四川
日期:2017-02-07 21:08:572015年亚冠纪念徽章
日期:2015-11-06 12:31:58每日论坛发贴之星
日期:2015-08-04 06:20:00程序设计版块每日发帖之星
日期:2015-08-04 06:20:00程序设计版块每日发帖之星
日期:2015-07-12 22:20:002015亚冠之浦和红钻
日期:2015-07-08 10:10:132015亚冠之大阪钢巴
日期:2015-06-29 11:21:122015亚冠之广州恒大
日期:2015-05-22 21:55:412015年亚洲杯之伊朗
日期:2015-04-10 16:28:25
18 [报告]
发表于 2010-03-02 15:25 |只看该作者
我有多个.a文件:liba.a libb.a libc.a
然后将它们用下面的目录打包在一个.a文件中:
$ ar -rcs libobj.a ...
wooin 发表于 2009-12-21 19:22



    键一个目录,把n多.a拆到这个目录,然后打包成一个.a。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP