ar(1) CLIX ar(1)
NAME
ar - Archives and maintains files for portable archives
SYNOPSIS
ar flag [posname] afile [name] ...
FLAGS
Unlike other commands, the flag is a required part of the command line of
ar. Arguments to the flag are described after the list of flags.
-d Deletes the named files from the archive file.
-r Replaces the named files in the archive file. If the optional
argument u is used with -r, then only those files with dates of
modification later than the archive files are replaced. If an
optional positioning argument a, b, or i is used, then the posname
argument must be present and specifies that new files are to be
placed after (a) or before (b or i) posname. Otherwise, new files
are placed at the end.
-q Quickly appends the named files to the end of the archive file.
Optional positioning arguments are invalid. The command does not
check whether the added members are already in the archive. This
flag 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.
-t Displays 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.
-p Displays the named files in the archive.
-m Moves 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, specifies where the files are to be moved.
-x Extracts 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 flag arguments are as follows:
a Places new files after position_name. (The position_name argument
must be present.) Applies only to the -m and -r flags.
b Places new files before position_name. (The position_name argument
must be present.) Applies only to the -m and -r flags.
2/94 - Intergraph Corporation 1
ar(1) CLIX ar(1)
i Same as the b flag argument.
u (Update.) Replaces only those files that have changed since they were
placed in the archive. Used with the -r flag.
v Gives 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, gives a long listing of all information about the files.
When used with -x, precedes each file with a name.
c Suppresses the message that is produced by default when afile is
created.
l Places temporary files in the local (current working) directory rather
than in the default temporary directory $TMPDIR.
s Forces the regeneration of the archive symbol table even if ar 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
command has been used on the archive.
DESCRIPTION
The ar command maintains groups of files combined into a single archive
file. Its main use is to create and update library files as used by the
link editor. It can be used, though, for any similar purpose. The magic
string and the file headers used by ar consist of displayable ASCII
characters. If an archive is composed of displayable files, the entire
archive is displayable.
When ar creates an archive, it creates headers in a format that is
portable across all machines. The portable archive format and structure
is described in detail in ar(0). The archive symbol table (described in
ar(0)) is used by the link editor (ld) to effect multiple passes over
libraries of object files in an efficient manner. 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 which is always the first file in the archive. This file is never
mentioned or accessible to the user. Whenever the ar command is used to
create or update the contents of such an archive, the symbol table is
rebuilt. The -s flag will force the symbol table to be rebuilt.
The posname argument is an archive member name used as a reference point
in positioning other files in the archive. The afile is the archive file.
The names are constituent files in the archive file.
EXAMPLES
1. To add myfile.o to the archive mylib.a:
ar -r mylib.a myfile.o
2 Intergraph Corporation - 2/94
ar(1) CLIX ar(1)
2. To delete the file myfile.o from the archive mylib.a:
ar -d mylib.a myfile.o
3. To extract a copy of myfile.o into the current directory:
ar -x mylib.a myfile.o
FILES
$TMPDIR/* Temporary files.
The $TMPDIR is usually /usr/tmp but can be redefined by setting the
environment variable $TMPDIR (see tempnam() in tmpnam(3)).
CAUTIONS
If the same file is mentioned twice in an argument list, it may be put in
the archive twice.
EXIT VALUES
Exits with 0 if successful.
RELATED INFORMATION
Commands: ld(1), lorder(1), strip(1)
Functions: tmpnam(3)
Files: a.out(4), ar(0)
2/94 - Intergraph Corporation 3