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/

相关内容

热门资讯

山水皆有情!丽江两山一江的千年... 去过丽江、走过虎跳峡的人,大概率都听过哈巴雪山和金沙江的传说。很多人站在峡谷之下,望着奔腾不息的金沙...
活力中国调研行丨“殷”你而来 ... 9月12日,游客在殷墟博物馆“甲骨文展厅”内参观。位于河南省安阳市的殷墟博物馆新馆是首个全景式展现商...
浦江之夜赴美好相逢,第37届上... 9月12日晚,黄浦江畔灯火璀璨,第37届上海旅游节大巡游在外滩中山东一路上演。不少观众早早便来到外滩...
美丽中国丨秋韵紫鹊界 梯田入画... 这是9月11日拍摄的紫鹊界梯田(无人机照片)。 金秋九月,湖南省娄底市新化县紫鹊界梯田稻谷渐次成熟。...
中国之巅奏响《共同的节日》,千... 千吨阻尼器,“迎世赛、游上海旅游节”。9月13日,由上海市文化和旅游局指导推出上海旅游·会客│巅峰之...