1<html lang="en"> 2<head> 3<title>ar cmdline - GNU Binary Utilities</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="GNU Binary Utilities"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="ar.html#ar" title="ar"> 9<link rel="next" href="ar-scripts.html#ar-scripts" title="ar scripts"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1991-2013 Free Software Foundation, Inc. 13 14Permission is granted to copy, distribute and/or modify this document 15under the terms of the GNU Free Documentation License, Version 1.3 16or any later version published by the Free Software Foundation; 17with no Invariant Sections, with no Front-Cover Texts, and with no 18Back-Cover Texts. A copy of the license is included in the 19section entitled ``GNU Free Documentation License''. 20 21--> 22<meta http-equiv="Content-Style-Type" content="text/css"> 23<style type="text/css"><!-- 24 pre.display { font-family:inherit } 25 pre.format { font-family:inherit } 26 pre.smalldisplay { font-family:inherit; font-size:smaller } 27 pre.smallformat { font-family:inherit; font-size:smaller } 28 pre.smallexample { font-size:smaller } 29 pre.smalllisp { font-size:smaller } 30 span.sc { font-variant:small-caps } 31 span.roman { font-family:serif; font-weight:normal; } 32 span.sansserif { font-family:sans-serif; font-weight:normal; } 33--></style> 34<link rel="stylesheet" type="text/css" href="../cs.css"> 35</head> 36<body> 37<div class="node"> 38<a name="ar-cmdline"></a> 39<p> 40Next: <a rel="next" accesskey="n" href="ar-scripts.html#ar-scripts">ar scripts</a>, 41Up: <a rel="up" accesskey="u" href="ar.html#ar">ar</a> 42<hr> 43</div> 44 45<h3 class="section">1.1 Controlling <samp><span class="command">ar</span></samp> on the Command Line</h3> 46 47<pre class="smallexample"> <!-- man begin SYNOPSIS ar --> 48 ar [<samp><span class="option">--plugin</span></samp> <var>name</var>] [<samp><span class="option">-X32_64</span></samp>] [<samp><span class="option">-</span></samp>]<var>p</var>[<var>mod</var> [<var>relpos</var>] [<var>count</var>]] [<samp><span class="option">--target</span></samp> <var>bfdname</var>] <var>archive</var> [<var>member</var>...] 49 <!-- man end --> 50</pre> 51 <p><a name="index-Unix-compatibility_002c-_0040command_007bar_007d-11"></a>When you use <samp><span class="command">ar</span></samp> in the Unix style, <samp><span class="command">ar</span></samp> insists on at least two 52arguments to execute: one keyletter specifying the <em>operation</em> 53(optionally accompanied by other keyletters specifying 54<em>modifiers</em>), and the archive name to act on. 55 56 <p>Most operations can also accept further <var>member</var> arguments, 57specifying particular files to operate on. 58 59<!-- man begin OPTIONS ar --> 60 <p><span class="sc">gnu</span> <samp><span class="command">ar</span></samp> allows you to mix the operation code <var>p</var> and modifier 61flags <var>mod</var> in any order, within the first command-line argument. 62 63 <p>If you wish, you may begin the first command-line argument with a 64dash. 65 66 <p><a name="index-operations-on-archive-12"></a>The <var>p</var> keyletter specifies what operation to execute; it may be 67any of the following, but you must specify only one of them: 68 69 <dl> 70<dt>‘<samp><span class="samp">d</span></samp>’<dd><a name="index-deleting-from-archive-13"></a><em>Delete</em> modules from the archive. Specify the names of modules to 71be deleted as <var>member</var><small class="dots">...</small>; the archive is untouched if you 72specify no files to delete. 73 74 <p>If you specify the ‘<samp><span class="samp">v</span></samp>’ modifier, <samp><span class="command">ar</span></samp> lists each module 75as it is deleted. 76 77 <br><dt>‘<samp><span class="samp">m</span></samp>’<dd><a name="index-moving-in-archive-14"></a>Use this operation to <em>move</em> members in an archive. 78 79 <p>The ordering of members in an archive can make a difference in how 80programs are linked using the library, if a symbol is defined in more 81than one member. 82 83 <p>If no modifiers are used with <code>m</code>, any members you name in the 84<var>member</var> arguments are moved to the <em>end</em> of the archive; 85you can use the ‘<samp><span class="samp">a</span></samp>’, ‘<samp><span class="samp">b</span></samp>’, or ‘<samp><span class="samp">i</span></samp>’ modifiers to move them to a 86specified place instead. 87 88 <br><dt>‘<samp><span class="samp">p</span></samp>’<dd><a name="index-printing-from-archive-15"></a><em>Print</em> the specified members of the archive, to the standard 89output file. If the ‘<samp><span class="samp">v</span></samp>’ modifier is specified, show the member 90name before copying its contents to standard output. 91 92 <p>If you specify no <var>member</var> arguments, all the files in the archive are 93printed. 94 95 <br><dt>‘<samp><span class="samp">q</span></samp>’<dd><a name="index-quick-append-to-archive-16"></a><em>Quick append</em>; Historically, add the files <var>member</var><small class="dots">...</small> to the end of 96<var>archive</var>, without checking for replacement. 97 98 <p>The modifiers ‘<samp><span class="samp">a</span></samp>’, ‘<samp><span class="samp">b</span></samp>’, and ‘<samp><span class="samp">i</span></samp>’ do <em>not</em> affect this 99operation; new members are always placed at the end of the archive. 100 101 <p>The modifier ‘<samp><span class="samp">v</span></samp>’ makes <samp><span class="command">ar</span></samp> list each file as it is appended. 102 103 <p>Since the point of this operation is speed, implementations of 104<samp><span class="command">ar</span></samp> have the option of not updating the archive's symbol 105table if one exists. Too many different systems however assume that 106symbol tables are always up-to-date, so <span class="sc">gnu</span> <samp><span class="command">ar</span></samp> will 107rebuild the table even with a quick append. 108 109 <p>Note - <span class="sc">gnu</span> <samp><span class="command">ar</span></samp> treats the command ‘<samp><span class="samp">qs</span></samp>’ as a 110synonym for ‘<samp><span class="samp">r</span></samp>’ - replacing already existing files in the 111archive and appending new ones at the end. 112 113 <br><dt>‘<samp><span class="samp">r</span></samp>’<dd><a name="index-replacement-in-archive-17"></a>Insert the files <var>member</var><small class="dots">...</small> into <var>archive</var> (with 114<em>replacement</em>). This operation differs from ‘<samp><span class="samp">q</span></samp>’ in that any 115previously existing members are deleted if their names match those being 116added. 117 118 <p>If one of the files named in <var>member</var><small class="dots">...</small> does not exist, <samp><span class="command">ar</span></samp> 119displays an error message, and leaves undisturbed any existing members 120of the archive matching that name. 121 122 <p>By default, new members are added at the end of the file; but you may 123use one of the modifiers ‘<samp><span class="samp">a</span></samp>’, ‘<samp><span class="samp">b</span></samp>’, or ‘<samp><span class="samp">i</span></samp>’ to request 124placement relative to some existing member. 125 126 <p>The modifier ‘<samp><span class="samp">v</span></samp>’ used with this operation elicits a line of 127output for each file inserted, along with one of the letters ‘<samp><span class="samp">a</span></samp>’ or 128‘<samp><span class="samp">r</span></samp>’ to indicate whether the file was appended (no old member 129deleted) or replaced. 130 131 <br><dt>‘<samp><span class="samp">s</span></samp>’<dd><a name="index-ranlib-18"></a>Add an index to the archive, or update it if it already exists. Note 132this command is an exception to the rule that there can only be one 133command letter, as it is possible to use it as either a command or a 134modifier. In either case it does the same thing. 135 136 <br><dt>‘<samp><span class="samp">t</span></samp>’<dd><a name="index-contents-of-archive-19"></a>Display a <em>table</em> listing the contents of <var>archive</var>, or those 137of the files listed in <var>member</var><small class="dots">...</small> that are present in the 138archive. Normally only the member name is shown; if you also want to 139see the modes (permissions), timestamp, owner, group, and size, you can 140request that by also specifying the ‘<samp><span class="samp">v</span></samp>’ modifier. 141 142 <p>If you do not specify a <var>member</var>, all files in the archive 143are listed. 144 145 <p><a name="index-repeated-names-in-archive-20"></a><a name="index-name-duplication-in-archive-21"></a>If there is more than one file with the same name (say, ‘<samp><span class="samp">fie</span></samp>’) in 146an archive (say ‘<samp><span class="samp">b.a</span></samp>’), ‘<samp><span class="samp">ar t b.a fie</span></samp>’ lists only the 147first instance; to see them all, you must ask for a complete 148listing—in our example, ‘<samp><span class="samp">ar t b.a</span></samp>’. 149<!-- WRS only; per Gumby, this is implementation-dependent, and in a more --> 150<!-- recent case in fact works the other way. --> 151 152 <br><dt>‘<samp><span class="samp">x</span></samp>’<dd><a name="index-extract-from-archive-22"></a><em>Extract</em> members (named <var>member</var>) from the archive. You can 153use the ‘<samp><span class="samp">v</span></samp>’ modifier with this operation, to request that 154<samp><span class="command">ar</span></samp> list each name as it extracts it. 155 156 <p>If you do not specify a <var>member</var>, all files in the archive 157are extracted. 158 159 <p>Files cannot be extracted from a thin archive. 160 161 <br><dt>‘<samp><span class="samp">--help</span></samp>’<dd>Displays the list of command line options supported by <samp><span class="command">ar</span></samp> 162and then exits. 163 164 <br><dt>‘<samp><span class="samp">--version</span></samp>’<dd>Displays the version information of <samp><span class="command">ar</span></samp> and then exits. 165 166 </dl> 167 168 <p>A number of modifiers (<var>mod</var>) may immediately follow the <var>p</var> 169keyletter, to specify variations on an operation's behavior: 170 171 <dl> 172<dt>‘<samp><span class="samp">a</span></samp>’<dd><a name="index-relative-placement-in-archive-23"></a>Add new files <em>after</em> an existing member of the 173archive. If you use the modifier ‘<samp><span class="samp">a</span></samp>’, the name of an existing archive 174member must be present as the <var>relpos</var> argument, before the 175<var>archive</var> specification. 176 177 <br><dt>‘<samp><span class="samp">b</span></samp>’<dd>Add new files <em>before</em> an existing member of the 178archive. If you use the modifier ‘<samp><span class="samp">b</span></samp>’, the name of an existing archive 179member must be present as the <var>relpos</var> argument, before the 180<var>archive</var> specification. (same as ‘<samp><span class="samp">i</span></samp>’). 181 182 <br><dt>‘<samp><span class="samp">c</span></samp>’<dd><a name="index-creating-archives-24"></a><em>Create</em> the archive. The specified <var>archive</var> is always 183created if it did not exist, when you request an update. But a warning is 184issued unless you specify in advance that you expect to create it, by 185using this modifier. 186 187 <br><dt>‘<samp><span class="samp">D</span></samp>’<dd><a name="index-deterministic-archives-25"></a><a name="index-g_t_002d_002denable_002ddeterministic_002darchives-26"></a>Operate in <em>deterministic</em> mode. When adding files and the archive 188index use zero for UIDs, GIDs, timestamps, and use consistent file modes 189for all files. When this option is used, if <samp><span class="command">ar</span></samp> is used with 190identical options and identical input files, multiple runs will create 191identical output files regardless of the input files' owners, groups, 192file modes, or modification times. 193 194 <p>If <samp><span class="file">binutils</span></samp> was configured with 195<samp><span class="option">--enable-deterministic-archives</span></samp>, then this mode is on by default. 196It can be disabled with the ‘<samp><span class="samp">U</span></samp>’ modifier, below. 197 198 <br><dt>‘<samp><span class="samp">f</span></samp>’<dd>Truncate names in the archive. <span class="sc">gnu</span> <samp><span class="command">ar</span></samp> will normally permit file 199names of any length. This will cause it to create archives which are 200not compatible with the native <samp><span class="command">ar</span></samp> program on some systems. If 201this is a concern, the ‘<samp><span class="samp">f</span></samp>’ modifier may be used to truncate file 202names when putting them in the archive. 203 204 <br><dt>‘<samp><span class="samp">i</span></samp>’<dd>Insert new files <em>before</em> an existing member of the 205archive. If you use the modifier ‘<samp><span class="samp">i</span></samp>’, the name of an existing archive 206member must be present as the <var>relpos</var> argument, before the 207<var>archive</var> specification. (same as ‘<samp><span class="samp">b</span></samp>’). 208 209 <br><dt>‘<samp><span class="samp">l</span></samp>’<dd>This modifier is accepted but not used. 210<!-- whaffor ar l modifier??? presumably compat; with --> 211<!-- what???-doc@@cygnus.com, 25jan91 --> 212 213 <br><dt>‘<samp><span class="samp">N</span></samp>’<dd>Uses the <var>count</var> parameter. This is used if there are multiple 214entries in the archive with the same name. Extract or delete instance 215<var>count</var> of the given name from the archive. 216 217 <br><dt>‘<samp><span class="samp">o</span></samp>’<dd><a name="index-dates-in-archive-27"></a>Preserve the <em>original</em> dates of members when extracting them. If 218you do not specify this modifier, files extracted from the archive 219are stamped with the time of extraction. 220 221 <br><dt>‘<samp><span class="samp">P</span></samp>’<dd>Use the full path name when matching names in the archive. <span class="sc">gnu</span> 222<samp><span class="command">ar</span></samp> can not create an archive with a full path name (such archives 223are not POSIX complaint), but other archive creators can. This option 224will cause <span class="sc">gnu</span> <samp><span class="command">ar</span></samp> to match file names using a complete path 225name, which can be convenient when extracting a single file from an 226archive created by another tool. 227 228 <br><dt>‘<samp><span class="samp">s</span></samp>’<dd><a name="index-writing-archive-index-28"></a>Write an object-file index into the archive, or update an existing one, 229even if no other change is made to the archive. You may use this modifier 230flag either with any operation, or alone. Running ‘<samp><span class="samp">ar s</span></samp>’ on an 231archive is equivalent to running ‘<samp><span class="samp">ranlib</span></samp>’ on it. 232 233 <br><dt>‘<samp><span class="samp">S</span></samp>’<dd><a name="index-not-writing-archive-index-29"></a>Do not generate an archive symbol table. This can speed up building a 234large library in several steps. The resulting archive can not be used 235with the linker. In order to build a symbol table, you must omit the 236‘<samp><span class="samp">S</span></samp>’ modifier on the last execution of ‘<samp><span class="samp">ar</span></samp>’, or you must run 237‘<samp><span class="samp">ranlib</span></samp>’ on the archive. 238 239 <br><dt>‘<samp><span class="samp">T</span></samp>’<dd><a name="index-creating-thin-archive-30"></a>Make the specified <var>archive</var> a <em>thin</em> archive. If it already 240exists and is a regular archive, the existing members must be present 241in the same directory as <var>archive</var>. 242 243 <br><dt>‘<samp><span class="samp">u</span></samp>’<dd><a name="index-updating-an-archive-31"></a>Normally, ‘<samp><span class="samp">ar r</span></samp>’<small class="dots">...</small> inserts all files 244listed into the archive. If you would like to insert <em>only</em> those 245of the files you list that are newer than existing members of the same 246names, use this modifier. The ‘<samp><span class="samp">u</span></samp>’ modifier is allowed only for the 247operation ‘<samp><span class="samp">r</span></samp>’ (replace). In particular, the combination ‘<samp><span class="samp">qu</span></samp>’ is 248not allowed, since checking the timestamps would lose any speed 249advantage from the operation ‘<samp><span class="samp">q</span></samp>’. 250 251 <br><dt>‘<samp><span class="samp">U</span></samp>’<dd><a name="index-deterministic-archives-32"></a><a name="index-g_t_002d_002denable_002ddeterministic_002darchives-33"></a>Do <em>not</em> operate in <em>deterministic</em> mode. This is the inverse 252of the ‘<samp><span class="samp">D</span></samp>’ modifier, above: added files and the archive index will 253get their actual UID, GID, timestamp, and file mode values. 254 255 <p>This is the default unless <samp><span class="file">binutils</span></samp> was configured with 256<samp><span class="option">--enable-deterministic-archives</span></samp>. 257 258 <br><dt>‘<samp><span class="samp">v</span></samp>’<dd>This modifier requests the <em>verbose</em> version of an operation. Many 259operations display additional information, such as filenames processed, 260when the modifier ‘<samp><span class="samp">v</span></samp>’ is appended. 261 262 <br><dt>‘<samp><span class="samp">V</span></samp>’<dd>This modifier shows the version number of <samp><span class="command">ar</span></samp>. 263</dl> 264 265 <p><samp><span class="command">ar</span></samp> ignores an initial option spelt ‘<samp><span class="samp">-X32_64</span></samp>’, for 266compatibility with AIX. The behaviour produced by this option is the 267default for <span class="sc">gnu</span> <samp><span class="command">ar</span></samp>. <samp><span class="command">ar</span></samp> does not support any of the other 268‘<samp><span class="samp">-X</span></samp>’ options; in particular, it does not support <samp><span class="option">-X32</span></samp> 269which is the default for AIX <samp><span class="command">ar</span></samp>. 270 271 <p>The optional command line switch <samp><span class="option">--plugin</span></samp> <var>name</var> causes 272<samp><span class="command">ar</span></samp> to load the plugin called <var>name</var> which adds support 273for more file formats. This option is only available if the toolchain 274has been built with plugin support enabled. 275 276 <p>The optional command line switch <samp><span class="option">--target</span></samp> <var>bfdname</var> 277specifies that the archive members are in an object code format 278different from your system's default format. See 279See <a href="Target-Selection.html#Target-Selection">Target Selection</a>, for more information. 280 281<!-- man end --> 282 </body></html> 283 284