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/

相关内容

热门资讯

甜蜜烘焙暖童心,亲子相伴庆六一 为让辖区儿童度过一个欢乐充实、富有意义的儿童节,在连云港市妇联“连慈妇爱”项目支持下,海州区新海街道...
原创 江... 一座侨都的烟火,从来不在网红扎堆的新店,而在熬得过岁月、守得住本味的老铺里。江门的美食,和这座城市的...
原创 一... 在日常饮食中,黑芝麻常被忽略,很多人觉得它只是小小调味料,偶尔撒在面包或拌入粥里。不过,你可知道,仅...
原创 再... 这4道汤品温润滋补,养胃不伤身、益肾强免疫,适合日常调养,坚持喝脾胃舒服、元气足、抵抗力更好。 一、...
原创 一... 大千世界总是令人很奇妙,当人们遇到不愉快的事情的时候,总是会被“做人咧,最紧要就系开心”这句经典台词...