Linuxubuntu操作系统下的ar命令

韵味老鸟 2024-08-12 18:02:41

Linux ubuntu操作系统下的 ar 命令

ar命令是Linux中用于创建、修改和提取静态库文件的工具。静态库是一种将多个目标文件(.o文件)打包成一个单一文件(通常以.a结尾)的方式,便于在C/C++程序开发中进行代码重用。

操作选项r:在库中插入模块(替换同名模块)。c:创建库(如果库已存在则不进行替换)。s:创建目标文件索引,加快访问速度。d:删除库中的成员文件。t:列出库中的成员文件。x:从库中提取成员文件。任选项v:显示详细信息。f:指定库文件名。u:仅插入较新文件。

ar 命令参考

root@uk8s:~# ar

Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...

ar -M [<mri-脚本]

命令:

d - 从归档文件中删除文件

m[ab] - 在归档文件中移动文件

p - 打印在归档文件中找到的文件

q[f] - 将文件快速追加到归档文件中

r[ab][f][u] - 替换归档文件中已有的文件或加入新文件

s - 作为 ranlib 工作

t[O][v] - display contents of the archive

x[o] - 从归档文件中分解文件

特定命令修饰符:

[a] - 将文件置于 [成员名] 之后

[b] - 将文件置于 [成员名] 之前 (于 [i] 相同)

[D] - 将 0 用于时间戳和 uid/gid(默认)

[D] - 使用实际时间戳和 uid/gid

[N] - 使用名称的实例 [数量]

[f] - 截去插入的文件名称

[P] - 在匹配时使用完整的路径名

[o] - 保留原来的日期

[O] - display offsets of files in the archive

[u] - 只替换比当前归档内容更新的文件

通用修饰符:

[c] - 不在必须创建库的时候给出警告

[s] - 创建归档索引 (cf. ranlib)

[l <text> ] - specify the dependencies of this library

[S] - 不要创建符号表

[T] - deprecated, use --thin instead

[v] - 输出较多信息

[V] - 显示版本号

@<file> - 从 <file> 读取选项

--target=BFDNAME - 指定目标对象格式为 BFDNAME

--output=DIRNAME - specify the output directory for extraction operations

--record-libdeps=<text> - specify the dependencies of this library

--thin - make a thin archive

可选项:

--plugin <p> - 加载指定的插件程序

仿真选项:

没有仿真特有的选项

ar:支持的目标: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pe-x86-64 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-bigobj-x86-64 pe-i386 srec symbolsrec verilog tekhex binary ihex plugin

0 阅读:10