← 返回命令列表

Linux command

ar 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Create

ar rcs [archive.a] [file1.o] [file2.o]

List

ar t [archive.a]

Extract

ar x [archive.a]

Extract

ar x [archive.a] [file.o]

Add

ar r [archive.a] [newfile.o]

Delete

ar d [archive.a] [file.o]

说明

ar creates, modifies, and extracts from archives. It's primarily used to create static libraries (.a files) from object files for use with the linker. Archives contain multiple files with a table of contents for quick access. Unlike tar, ar is optimized for random access to individual members.

参数

r
Insert (replace) files
c
Create archive
s
Create/update archive index (ranlib)
t
Table of contents
x
Extract files
d
Delete files
p
Print file contents to stdout
q
Quick append (no checking)
v
Verbose output
u
Update only newer files

FAQ

What is the ar command used for?

ar creates, modifies, and extracts from archives. It's primarily used to create static libraries (.a files) from object files for use with the linker. Archives contain multiple files with a table of contents for quick access. Unlike tar, ar is optimized for random access to individual members.

How do I run a basic ar example?

Run `ar rcs [archive.a] [file1.o] [file2.o]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does r do in ar?

Insert (replace) files