ar(CP) 6 January 1993 ar(CP) Name ar - archive and library maintainer for portable archives Syntax ar key [keyarg] [posname] afile [name] ... Description The ar command combines groups of files in a single archive file. Its primary use is to create and update linker library files, but it can be used for any similar purpose. ar's magic string and the file headers consist of printable ASCII characters, so if an archive is composed of printable files, the entire archive can be printed. Archives of text files created by ar are portable between implementations of System V. The portable archive format and structure is described in detail in the ar(FP) manual page. The archive symbol table is used by ld to effect multiple passes over libraries of object files. An archive symbol table is only created and maintained by ar when there is at least one object file in the archive. The archive symbol table is in a specially named file that is always the first file in the archive (this file is not accessible to the user). Whenever ar is used to create or update the contents of an archive, the symbol table is rebuilt. The long filename map is the second file in the archive (this file only exists if one or more archived files have long filenames). Previously, the ar format permitted archive members to have file names of up to 14 characters in length. Now longer file names are allowed. Thus, ar(FP) was changed to permit archiving files with such long names. In order to accommodate the longer file names without breaking backwards compatibil- ity, another specially-named archive member, the long filename map, was introduced. The long filename map comes right after the symbol table if any of the archived files have names longer than 14 characters. This means that both the symbol table and the longfilename map are optional, but when they both appear the longfilename map appears after the symbol table. The longfilename map contains a one-to-one mapping between the real filenames and coded files names that are used internally by ar. These coded names are not accessible by the user. Unlike command options, the key is a required part of ar's command line. The key (which may begin with a "-") is formed with one of the following letters: dmpqrtx. Arguments to the key are made with one or more of the following: abcilsuv. posname is an archive member name used as a refer- ence point in positioning other files in afile, the archive file. The names are constituent files in the archive file. The valid key characters are: <d> Delete the named files from the archive file. <m> Move the named files to the end of the archive. If a positioning character is present, then the posname argument must be present and, as in <r>, specify where the files are to be moved. <p> Print the named files in the archive. <q> Quickly append the named files to the end of the archive file. Optional positioning characters are invalid. The command does not check whether the added members are already in the archive. This option is useful to avoid quadratic behavior when creating a large archive piece-by-piece. Unchecked, the file may grow exponentially up to the second degree. <r> Replace the named files in the archive file. If the optional charac- ter <u> is used with <r>, then only those files with dates of modifi- cation later than the archive files are replaced. If an optional positioning character from the set abi is used, then the posname argument must be present and specify that new files are to be placed after (<a>) or before (<b> or <i>) posname. Otherwise new files are placed at the end. <t> Print a table of contents of the archive file. If no names are given, all files in the archive are tabled. If names are given, only those files are tabled. <x> Extract the named files. If no names are given, all files in the archive are extracted. In neither case does <x> alter the archive file. The meanings of the key arguments are as follows: <a> Used with the <m> or <r> key characters, it specifies that new files are to be placed after posname in the archive file. <b> Used with the <m> or <r> key characters, it specifies that new files are to be placed before posname in the archive file. <c> Suppress the message that is produced by default when afile is creat- ed. <i> Used with the <m> or <r> key characters, it specifies that new files are to be placed before posname in the archive file. <l> Place temporary files in the local (current working) directory rather than in the default temporary directory, TMPDIR. <s> Force the regeneration of the archive symbol table even if ar(CP) is not invoked with a command which will modify the archive contents. This command is useful to restore the archive symbol table after the strip(CP) command has been used on the archive. <u> When used with the <r> key character, then only updated versions of files in the archive are used to overwrite the originals. <v> Give a verbose file-by-file description of the making of a new archive file from the old archive and the constituent files. When used with <t>, give a long listing of all information about the files. When used with <x>, precede each file with a name. Files $TMPDIR/* temporary files $TMPDIR is usually /usr/tmp but can be redefined by set- ting the environment variable TMPDIR (see tempnam() in tmpnam(S)). Notes If you are using XENIX binaries, please refer to the ar(XNX) manual page for information on use with XENIX binaries. If the same file is mentioned twice in an argument list, it may be put in the archive twice. This utility determines whether an object file is in OMF or COFF format and executes the appropriate binaries in each case. Since this utility relies on the files in /lib/coff and /lib/xout, changing or moving any of those files results in an error. See also a.out(FP), ar(FP), ld(CP), lorder(CP), strip(CP), tsort(CP), tmpnam(S) Standards conformance ar is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989.