unix - 静态库创建

标签 unix linker unix-ar

一般情况下 我们使用 ar rcs 命令在 unix 上创建静态库。

这里的标志's'是什么意思 手册页说

Do not generate an archive symbol table. This can speed up building a large library in several steps. The resulting archive can not be used with the linker. In order to build a symbol table, you must omit the S modifier on the last execution of ar, or you must run ranlib on the archive.

我对这句话感到困惑 “生成的存档可以 不能与链接器一起使用。”。

在 ar 命令之后我们是否必须使用 ranlib 来创建静态库? ranlib 的用途是什么以及如何使用?

最佳答案

ranlib 实用程序在库中创建索引,链接器使用该索引进行查找。请注意,ar 中的省略索引命令是大写的 S - 构建索引的命令是小写的 s,您应该使用它。运行ar rcs后无需再使用ranlib

关于unix - 静态库创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3054705/

相关文章:

linux - 删除每行末尾的 ';'

unix - 搜索文件并对每个结果运行脚本 - 续 :

build - 链接器和 makefile 之间有什么区别?

c++ - C++ 命名空间中的内联函数

c - 为什么信号处理程序中的 waitpid 需要循环?

file - 'read'中的 'unistd.h'函数的读取限制是多少?

c - LNK1120、LNK2001、LNK2019 - 无法追踪原因

c - 使用 fwrite 将 ar_hdr 结构存储到文件

c++ - 将静态库链接到其他静态库

c++ - Mac Lion 无法使用 'ar'、 'no symbols' 创建库