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

NAME

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

SYNOPSIS

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

DESCRIPTION

12       The  GNU  ar program creates, modifies, and extracts from archives.  An
13       archive is a single file holding a  collection  of  other  files  in  a
14       structure  that  makes  it possible to retrieve the original individual
15       files (called members of the archive).
16
17       The original files' contents, mode (permissions), timestamp, owner, and
18       group are preserved in the archive, and can be restored on extraction.
19
20       GNU  ar  can  maintain archives whose members have names of any length;
21       however, depending on how ar is configured on your system, a  limit  on
22       member-name  length  may be imposed for compatibility with archive for‐
23       mats maintained with other tools.  If it exists, the limit is often  15
24       characters (typical of formats related to a.out) or 16 characters (typ‐
25       ical of formats related to coff).
26
27       ar is considered a binary utility because archives  of  this  sort  are
28       most often used as libraries holding commonly needed subroutines.
29
30       ar  creates  an index to the symbols defined in relocatable object mod‐
31       ules in the archive when you specify the  modifier  s.   Once  created,
32       this  index is updated in the archive whenever ar makes a change to its
33       contents (save for the q update operation).  An archive  with  such  an
34       index  speeds  up  linking  to  the library, and allows routines in the
35       library to call each other without regard to their placement in the ar‐
36       chive.
37
38       You  may use nm -s or nm --print-armap to list this index table.  If an
39       archive lacks the table, another form of ar called ranlib can  be  used
40       to add just the table.
41
42       GNU ar is designed to be compatible with two different facilities.  You
43       can control its activity using command-line options, like the different
44       varieties of ar on Unix systems; or, if you specify the single command-
45       line option -M, you can control it with a script supplied via  standard
46       input, like the MRI "librarian" program.
47

OPTIONS

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

SEE ALSO

222       nm(1), ranlib(1), and the Info entries for binutils.
223
225       Copyright (c) 1991, 1992, 1993, 1994, 1995,  1996,  1997,  1998,  1999,
226       2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
227
228       Permission  is  granted to copy, distribute and/or modify this document
229       under the terms of the GNU Free Documentation License, Version  1.1  or
230       any  later  version  published by the Free Software Foundation; with no
231       Invariant Sections, with no Front-Cover Texts, and with  no  Back-Cover
232       Texts.   A copy of the license is included in the section entitled "GNU
233       Free Documentation License".
234
235
236
237binutils-2.17                     2006-06-23                             AR(1)
Impressum