1AR(1)                        GNU Development Tools                       AR(1)
2
3
4

NAME

6       ar - create, modify, and extract from archives
7

SYNOPSIS

9       ar [--plugin name] [-X32_64] [-]p[mod [relpos] [count]] archive
10       [member...]
11

DESCRIPTION

13       The GNU ar program creates, modifies, and extracts from archives.  An
14       archive is a single file holding a collection of other files in a
15       structure that makes it possible to retrieve the original individual
16       files (called members of the archive).
17
18       The original files' contents, mode (permissions), timestamp, owner, and
19       group are preserved in the archive, and can be restored on extraction.
20
21       GNU ar can maintain archives whose members have names of any length;
22       however, depending on how ar is configured on your system, a limit on
23       member-name length may be imposed for compatibility with archive
24       formats maintained with other tools.  If it exists, the limit is often
25       15 characters (typical of formats related to a.out) or 16 characters
26       (typical of formats related to coff).
27
28       ar is considered a binary utility because archives of this sort are
29       most often used as libraries holding commonly needed subroutines.
30
31       ar creates an index to the symbols defined in relocatable object
32       modules in the archive when you specify the modifier s.  Once created,
33       this index is updated in the archive whenever ar makes a change to its
34       contents (save for the q update operation).  An archive with such an
35       index speeds up linking to the library, and allows routines in the
36       library to call each other without regard to their placement in the
37       archive.
38
39       You may use nm -s or nm --print-armap to list this index table.  If an
40       archive lacks the table, another form of ar called ranlib can be used
41       to add just the table.
42
43       GNU ar can optionally create a thin archive, which contains a symbol
44       index and references to the original copies of the member files of the
45       archives.  Such an archive is useful for building libraries for use
46       within a local build, where the relocatable objects are expected to
47       remain available, and copying the contents of each object would only
48       waste time and space.  Thin archives are also flattened, so that adding
49       one or more archives to a thin archive will add the elements of the
50       nested archive individually.  The paths to the elements of the archive
51       are stored relative to the archive itself.
52
53       GNU ar is designed to be compatible with two different facilities.  You
54       can control its activity using command-line options, like the different
55       varieties of ar on Unix systems; or, if you specify the single command-
56       line option -M, you can control it with a script supplied via standard
57       input, like the MRI "librarian" program.
58

OPTIONS

60       GNU ar allows you to mix the operation code p and modifier flags mod in
61       any order, within the first command-line argument.
62
63       If you wish, you may begin the first command-line argument with a dash.
64
65       The p keyletter specifies what operation to execute; it may be any of
66       the following, but you must specify only one of them:
67
68       d   Delete modules from the archive.  Specify the names of modules to
69           be deleted as member...; the archive is untouched if you specify no
70           files to delete.
71
72           If you specify the v modifier, ar lists each module as it is
73           deleted.
74
75       m   Use this operation to move members in an archive.
76
77           The ordering of members in an archive can make a difference in how
78           programs are linked using the library, if a symbol is defined in
79           more than one member.
80
81           If no modifiers are used with "m", any members you name in the
82           member arguments are moved to the end of the archive; you can use
83           the a, b, or i modifiers to move them to a specified place instead.
84
85       p   Print the specified members of the archive, to the standard output
86           file.  If the v modifier is specified, show the member name before
87           copying its contents to standard output.
88
89           If you specify no member arguments, all the files in the archive
90           are printed.
91
92       q   Quick append; Historically, add the files member... to the end of
93           archive, without checking for replacement.
94
95           The modifiers a, b, and i do not affect this operation; new members
96           are always placed at the end of the archive.
97
98           The modifier v makes ar list each file as it is appended.
99
100           Since the point of this operation is speed, the archive's symbol
101           table index is not updated, even if it already existed; you can use
102           ar s or ranlib explicitly to update the symbol table index.
103
104           However, too many different systems assume quick append rebuilds
105           the index, so GNU ar implements q as a synonym for r.
106
107       r   Insert the files member... into archive (with replacement). This
108           operation differs from q in that any previously existing members
109           are deleted if their names match those being added.
110
111           If one of the files named in member... does not exist, ar displays
112           an error message, and leaves undisturbed any existing members of
113           the archive matching that name.
114
115           By default, new members are added at the end of the file; but you
116           may use one of the modifiers a, b, or i to request placement
117           relative to some existing member.
118
119           The modifier v used with this operation elicits a line of output
120           for each file inserted, along with one of the letters a or r to
121           indicate whether the file was appended (no old member deleted) or
122           replaced.
123
124       s   Add an index to the archive, or update it if it already exists.
125           Note this command is an exception to the rule that there can only
126           be one command letter, as it is possible to use it as either a
127           command or a modifier.  In either case it does the same thing.
128
129       t   Display a table listing the contents of archive, or those of the
130           files listed in member... that are present in the archive.
131           Normally only the member name is shown; if you also want to see the
132           modes (permissions), timestamp, owner, group, and size, you can
133           request that by also specifying the v modifier.
134
135           If you do not specify a member, all files in the archive are
136           listed.
137
138           If there is more than one file with the same name (say, fie) in an
139           archive (say b.a), ar t b.a fie lists only the first instance; to
140           see them all, you must ask for a complete listing---in our example,
141           ar t b.a.
142
143       x   Extract members (named member) from the archive.  You can use the v
144           modifier with this operation, to request that ar list each name as
145           it extracts it.
146
147           If you do not specify a member, all files in the archive are
148           extracted.
149
150           Files cannot be extracted from a thin archive.
151
152       A number of modifiers (mod) may immediately follow the p keyletter, to
153       specify variations on an operation's behavior:
154
155       a   Add new files after an existing member of the archive.  If you use
156           the modifier a, the name of an existing archive member must be
157           present as the relpos argument, before the archive specification.
158
159       b   Add new files before an existing member of the archive.  If you use
160           the modifier b, the name of an existing archive member must be
161           present as the relpos argument, before the archive specification.
162           (same as i).
163
164       c   Create the archive.  The specified archive is always created if it
165           did not exist, when you request an update.  But a warning is issued
166           unless you specify in advance that you expect to create it, by
167           using this modifier.
168
169       D   Operate in deterministic mode.  When adding files and the archive
170           index use zero for UIDs, GIDs, timestamps, and use consistent file
171           modes for all files.  When this option is used, if ar is used with
172           identical options and identical input files, multiple runs will
173           create identical output files regardless of the input files'
174           owners, groups, file modes, or modification times.
175
176       f   Truncate names in the archive.  GNU ar will normally permit file
177           names of any length.  This will cause it to create archives which
178           are not compatible with the native ar program on some systems.  If
179           this is a concern, the f modifier may be used to truncate file
180           names when putting them in the archive.
181
182       i   Insert new files before an existing member of the archive.  If you
183           use the modifier i, the name of an existing archive member must be
184           present as the relpos argument, before the archive specification.
185           (same as b).
186
187       l   This modifier is accepted but not used.
188
189       N   Uses the count parameter.  This is used if there are multiple
190           entries in the archive with the same name.  Extract or delete
191           instance count of the given name from the archive.
192
193       o   Preserve the original dates of members when extracting them.  If
194           you do not specify this modifier, files extracted from the archive
195           are stamped with the time of extraction.
196
197       P   Use the full path name when matching names in the archive.  GNU ar
198           can not create an archive with a full path name (such archives are
199           not POSIX complaint), but other archive creators can.  This option
200           will cause GNU ar to match file names using a complete path name,
201           which can be convenient when extracting a single file from an
202           archive created by another tool.
203
204       s   Write an object-file index into the archive, or update an existing
205           one, even if no other change is made to the archive.  You may use
206           this modifier flag either with any operation, or alone.  Running ar
207           s on an archive is equivalent to running ranlib on it.
208
209       S   Do not generate an archive symbol table.  This can speed up
210           building a large library in several steps.  The resulting archive
211           can not be used with the linker.  In order to build a symbol table,
212           you must omit the S modifier on the last execution of ar, or you
213           must run ranlib on the archive.
214
215       T   Make the specified archive a thin archive.  If it already exists
216           and is a regular archive, the existing members must be present in
217           the same directory as archive.
218
219       u   Normally, ar r... inserts all files listed into the archive.  If
220           you would like to insert only those of the files you list that are
221           newer than existing members of the same names, use this modifier.
222           The u modifier is allowed only for the operation r (replace).  In
223           particular, the combination qu is not allowed, since checking the
224           timestamps would lose any speed advantage from the operation q.
225
226       v   This modifier requests the verbose version of an operation.  Many
227           operations display additional information, such as filenames
228           processed, when the modifier v is appended.
229
230       V   This modifier shows the version number of ar.
231
232       ar ignores an initial option spelt -X32_64, for compatibility with AIX.
233       The behaviour produced by this option is the default for GNU ar.  ar
234       does not support any of the other -X options; in particular, it does
235       not support -X32 which is the default for AIX ar.
236
237       The optional command line switch --plugin name causes ar to load the
238       plugin called name which adds support for more file formats.  This
239       option is only available if the toolchain has been built with plugin
240       support enabled.
241
242       @file
243           Read command-line options from file.  The options read are inserted
244           in place of the original @file option.  If file does not exist, or
245           cannot be read, then the option will be treated literally, and not
246           removed.
247
248           Options in file are separated by whitespace.  A whitespace
249           character may be included in an option by surrounding the entire
250           option in either single or double quotes.  Any character (including
251           a backslash) may be included by prefixing the character to be
252           included with a backslash.  The file may itself contain additional
253           @file options; any such options will be processed recursively.
254

SEE ALSO

256       nm(1), ranlib(1), and the Info entries for binutils.
257
259       Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
260       2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
261       Software Foundation, Inc.
262
263       Permission is granted to copy, distribute and/or modify this document
264       under the terms of the GNU Free Documentation License, Version 1.3 or
265       any later version published by the Free Software Foundation; with no
266       Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
267       Texts.  A copy of the license is included in the section entitled "GNU
268       Free Documentation License".
269
270
271
272binutils-2.21                     2010-12-08                             AR(1)
Impressum