|GNU Binary Utilities|
ar [--plugin name] [-X32_64] [-]p[mod [relpos] [count]] [--target bfdname] archive [member...]
When you use ar in the Unix style, ar insists on at least two arguments to execute: one keyletter specifying the operation (optionally accompanied by other keyletters specifying modifiers), and the archive name to act on.
Most operations can also accept further member arguments, specifying particular files to operate on.
gnu ar allows you to mix the operation code p and modifier flags mod in any order, within the first command-line argument.
If you wish, you may begin the first command-line argument with a dash.
If you specify the ‘v’ modifier, ar lists each module
as it is deleted.
The ordering of members in an archive can make a difference in how programs are linked using the library, if a symbol is defined in more than one member.
If no modifiers are used with
m, any members you name in the
member arguments are moved to the end of the archive;
you can use the ‘a’, ‘b’, or ‘i’ modifiers to move them to a
specified place instead.
If you specify no member arguments, all the files in the archive are
The modifiers ‘a’, ‘b’, and ‘i’ do not affect this operation; new members are always placed at the end of the archive.
The modifier ‘v’ makes ar list each file as it is appended.
Since the point of this operation is speed, the archive's symbol table index is not updated, even if it already existed; you can use ‘ar s’ or ranlib explicitly to update the symbol table index.
However, too many different systems assume quick append rebuilds the
index, so gnu ar implements ‘q’ as a synonym for ‘r’.
If one of the files named in member... does not exist, ar displays an error message, and leaves undisturbed any existing members of the archive matching that name.
By default, new members are added at the end of the file; but you may use one of the modifiers ‘a’, ‘b’, or ‘i’ to request placement relative to some existing member.
The modifier ‘v’ used with this operation elicits a line of
output for each file inserted, along with one of the letters ‘a’ or
‘r’ to indicate whether the file was appended (no old member
deleted) or replaced.
If you do not specify a member, all files in the archive are listed.
If there is more than one file with the same name (say, ‘fie’) in
an archive (say ‘b.a’), ‘ar t b.a fie’ lists only the
first instance; to see them all, you must ask for a complete
listing—in our example, ‘ar t b.a’.
If you do not specify a member, all files in the archive are extracted.
Files cannot be extracted from a thin archive.
A number of modifiers (mod) may immediately follow the p keyletter, to specify variations on an operation's behavior:
If binutils was configured with
--enable-deterministic-archives, then this mode is on by default.
It can be disabled with the ‘U’ modifier, below.
This is the default unless binutils was configured with
ar ignores an initial option spelt ‘-X32_64’, for compatibility with AIX. The behaviour produced by this option is the default for gnu ar. ar does not support any of the other ‘-X’ options; in particular, it does not support -X32 which is the default for AIX ar.
The optional command line switch --plugin name causes ar to load the plugin called name which adds support for more file formats. This option is only available if the toolchain has been built with plugin support enabled.
The optional command line switch --target bfdname specifies that the archive members are in an object code format different from your system's default format. See See Target Selection, for more information.