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/

相关内容

热门资讯

天山冰雪迎客来(图片新闻) 天... 新疆维吾尔自治区昌吉回族自治州天山天池风景区利用丰富的冰雪旅游资源开展多场文化、体育、旅游等冰雪相关...
喝酒,要选晚上,才不会误事!暮... 喝酒,要选晚上,才不会误事! 暮色四合时小酌最为相宜。这不仅顺应人体自然节律,更蕴含着养生妙谛。晨...
吃广西横县的鸭肉生,端上桌鸭肉... 作者丨发财金刚 广西横县人对美食的追求,有自己的一套赤诚法则。 高端的食材往往只需要简单的烹饪,这句...
白茶的冲泡方法 冲泡白茶常见的方法有杯泡法、壶泡法、煮饮法、盖碗法、冷泡法等。 (1) 杯泡法。对于白毫银针和等级较...
原创 川... 标题:川菜大厨:腌腊肉时,别只会放盐,多做2步,腊味提升“1倍” 在四川的厨房里,腌制腊肉是一门艺...