c - ar 中的 “rcs“选项有什么作用?
admin
2024-02-12 23:42:46

c - ar 中的 "rcs"选项有什么作用?

我确实阅读了 man 文件,但它没有帮助。 rcs似乎是传递给 ar 的最流行的选项,但对我来说含义不是很清楚。
所以c意味着创建一个新的存档,但是为什么要使用 r ?这似乎代表“替换”? s 会怎样?选项做输出?

最佳答案

阅读manual page (for ar) 是一个好的开始:

c

Create the archive. The specified archive is always created if it did not exist, when you request an update. But a warning is issued unless you specify in advance that you expect to create it, by using this modifier.

r

Insert the files member… into archive (with replacement). This operation differs from q in that any previously existing members are deleted if their names match those being added.

s

Write an object-file index into the archive, or update an existing one, even if no other change is made to the archive. You may use this modifier flag either with any operation, or alone. Running “ar s” on an archive is equivalent to running ranlib on it.

与 POSIX 比较,您可能会注意到一个区别:GNU ar 使“-”前缀选项本身是可选的。

文件可以包含除目标文件之外的其他项目(尽管这并不经常这样做)。包含目标文件的文件需要额外的维护(例如,由 ranlib 完成)以使链接器可以使用它们。

根据Rationale在 POSIX ar 中,-s选项起源于 BSD(系统 V 自动执行此操作)。但是,运行 ranlib其本身就是流行的做法(-s 很少使用)。有趣的是,POSIX 没有 ranlib ,最后是 -s选项将替换 ranlib在众多为在各种平台上运行而编写的 makefile 中。
关于c - ar 中的 "rcs"选项有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29714300/

相关内容

热门资讯

同样卖奶茶,为何古茗赚了15亿... 出品/联商专栏 撰文/老刀 编辑/蔡建桢 今年上半年,蜜雪、古茗、霸王茶姬、茶百道、沪上阿姨全部盈利...
现烤散装走俏、新口味亮相、健康... 中秋佳节临近,成都月饼市场已全面开启“上新季”。记者连日来走访成都多家商超看到,月饼专区占据卖场核心...
散装月饼靠性价比当上“人气王” 华润超市货架上的散装月饼。 深圳报业集团记者 欧阳莹 摄 深圳晚报讯 (深圳报业集团记者 欧阳莹) ...
原创 9... 九月初秋,燥气渐起,容易咽喉干痒、口鼻缺水、干咳烦闷。多喝清润汤水,滋养肺阴,补足身体津液,不寒不腻...
原创 生... 山药是秋季深藏不露的养生食材,也是为数不多 生用补肾、熟用健脾 的平价好物。生山药滋阴补肾、固护肾精...