AR command Detailed

Source: Internet
Author: User
Tags sorts strcmp

AR command

Use

Maintains the index library used by the link editor.

Grammar

AR [-c] [-l] [-g |-O] [-S] [-v] [-c] [-t] [-z] {-H |  -P |  -T | -X} [-X {32|64|32_64}] archivefile [File ...]

AR [-c] [-l] [-g |-O] [-S] [-v] [-c] [-t] [-z] {-m |  -R [-u]} [{-a |  -B | -i} Positionname] [-x {32|64|32_64}] archivefile File ...

AR [-c] [-l] [-g |-O] [-S] [-v] [-c] [-t] [-z] {-D | -Q} [-X {32|64|32_64}] archivefile File ...

AR [-c] [-l] [-v] [-c] [-t] [-z] {-g |-O |  -S | -W} [-X {32|64|32_64}] Archivefile

Describe

The AR Command maintains the index library used by the link editor. The AR command merges one or more specified files into a single compressed document file written in AR compressed document format. When the AR command creates a library, it creates a transport-formatted header, which rebuilds the symbol table when it creates or updates the library. For information about the format and structure of index-compressed documents and symbol tables, see AR file format entries.

The AR command recognizes two file formats. The "Large compressed document Format" Ar_big is the default file format and supports 32-bit and 64-bit target files. Small compressed document format can be used to create compressed documents that are recognized on older versions of AIX 4.3, see the-G flag. If you add a 64-bit object to a small-format compressed document, AR first converts it to a large format unless-G is specified. By default, AR processes only 32-bit target files, and any 64-bit target files in the compressed document are ignored without prompting. To change this behavior, either use the-X flag or set the OBJECT_MODE environment variable.

Sign

In the AR command, you can specify any number of optional flags from the set CCLOSTV. You must specify a flag from the flag set DHMOPQRSTWX. If you select the-m or-R flag, you may also specify a location flag (-A,-B, or-i), and for the-a,-B, or-I flag, you must also specify the name of a file in Archivefile (Positionname), which is immediately after the list of flags and is separated by a space.

-a positionname places the specified file after the existing file that is identified by the Positionname parameter.

-B positionname Place the specified file before the existing file identified by the Positionname parameter.

-C disables the normal message generated when the library is created.

-C prevents the extracted files from replacing files with the same name in the file system.

-d deletes the specified file from the library.

-G sorts the compressed document members to ensure maximum load efficiency with a minimum amount of unused space. In almost all cases, the-G flag physically places them in the logical link order of the compressed document members. The resulting compressed document is usually written in small format so that the flag can be used to convert large format compressed documents into small format compressed documents. Compressed documents containing 64-bit XCOFF objects cannot be created or converted to small format.

-H Sets the modified time in the member header of the specified file to the current date and time. If you do not specify any file names, the AR command sets the timestamp for all member headers. This flag cannot be used with the-Z flag.

-I positionname place the specified file (same as-B) before the existing file identified by the Positionname parameter.

-L places the temporary file in the current (local) directory instead of the TMPDIR directory (the default is/tmp).

-M moves the specified file to a different location in the library. By default, it moves the specified file to the end of the library. Use the location flag (ABI) to specify a different location.

-O Sorts the compressed document members to ensure maximum load efficiency with a minimum amount of unused space. In almost all cases, the-O flag physically places them in a logical link order that compresses the members of the document. The resulting compressed document is usually written in large format so that it can be used to convert small-format compressed documents into large-format compressed documents.

-P writes the contents of the file specified in the files parameter or all files specified in the Archivefile parameter (if you do not specify any files) to standard output.

-Q adds the specified file to the end of the library. Also, if you specify the same file two times, it may be placed in the library two times.

-r If the specified file already exists in the library, replace it. Because the specified files occupy the same location in the library as the files they replace, the location flags have no additional effect. When used with the-U flag (update), the-R flag replaces only files that have been modified since the last time it was added to the library.

If the specified file does not exist in the library, the AR command adds it. In this case, the position flag affects the placement. If you do not specify a location, the new file is placed at the end of the library. If you specify the same file two times, it may be placed in the library two times.

-S forces the library symbol table to be rebuilt regardless of whether the AR command modifies the library contents. Use this flag to restore the library symbol table after you use the Strip command on the library.

-T writes the library's directory to standard output. If you specify a file name, only those files that are specified are displayed. If you do not specify any files, the-t flag lists all the files in the library.

-T allows file names to be truncated if the compressed document member name is longer than the file system supports. This option is not valid because the file system supports a name length equal to 255 characters for a maximum compressed document member name.

-U only copies files that have changed since they were last copied (see the-R flag discussed previously).

-V writes a detailed file-by-document description of the new library to standard output. When used with the-t flag, it gives a long list similar to the Ls-l command. When used with the-X flag, it adds a name in front of each file. When used with the-H flag, it lists the member name and the modified time of the update.

-W Displays the compressed document symbol table. Each symbol is listed together with the name of the file in which this symbol is defined.

-X unzip them by copying the specified files to the current directory. These replicas have the same name as the original file (which remains in the library). If you do not specify any files, the-X flag copies all the files in the library. This procedure does not change the library.

-X mode specifies the type of target file that AR should check. Mode must be one of the following:

32

Processing only 32-bit target files

64

Processing only 64-bit target files

32_64

Processing 32-bit and 64-bit target files

The default value is to process 32-bit target files (ignoring 64-bit objects). Mode can also be set using the OBJECT_MODE environment variable. For example, object_mode=64 causes AR to process any 64-bit objects and ignores 32-bit objects. The-X flag overrides the Object_mode variable.

-Z creates a temporary copy of the compressed document and performs all required modifications to the copy. When all operations successfully complete, the working copy of the compressed document overwrites the original copy. This flag cannot be used with the-H flag.

ARCHIVEFILE Specifies the name of the compressed document file;

MemberName ... The name of each compressed document member.

Exit status

The command returns the following exit values:

0 completed successfully.

>0 an error occurred.

Example

1. To create a library, enter:

Ar-v-Q LIB.A strlen.o strcpy.o

If the LIB.A library does not exist, this command creates it and enters a copy of the file strlen.o and strcpy.o. If the LIB.A library exists, this command adds the new member to the end without checking the same member. The V flag is set in verbose mode, in which the AR command displays the process report when it is in progress.

2. To display the library's directory, enter:

Ar-v-T LIB.A

This command lists the directories for the LIB.A library and displays a long list of outputs similar to the LS-L command. To list only member file names, omit the-v flag.

3. To replace or add a new member to the library, enter:

Ar-v-R LIB.A strlen.o STRCAT.O

This command replaces the members STRLEN.O and STRCAT.O. If LIB.A is created as shown in Example 1, the STRLEN.O member is replaced. Because there is no member named STRCAT.O, it is added to the end of the library.

4. To specify where to insert the new member, enter:

Ar-v-r-b STRLEN.O LIB.A STRCMP.O

This command adds a STRCMP.O file and places the new member before the STRLEN.O member.

5. To update a member that has changed, enter:

Ar-v-r-u LIB.A strcpy.o

This command replaces the existing STRCPY.O member, but replaces it only if the file STRCPY.O has been modified since the last time it was added to the library.

6. To change the order of library members, enter:

Ar-v-m-a strcmp.o LIB.A strcat.o strcpy.o

This command moves the members STRCAT.O and STRCPY.O to the location immediately following the STRCMP.O member. Retains the relative order of STRCAT.O and STRCPY.O members. In other words, if the STRCPY.O member precedes the STRCAT.O member before the move, it still does so (after moving).

7. To decompress a library member, enter:

Ar-v-X LIB.A strcat.o STRCPY.O

This command copies the members STRCAT.O and strcpy.o to files named STRCAT.O and STRCPY.O, respectively.

8. To decompress and rename a member, enter:

Ar-p LIB.A strcpy.o >stringcopy.o

This command copies the member strcpy.o to a file named STRINGCOPY.O.

9. To delete a member, enter:

Ar-v-D LIB.A STRLEN.O

This command removes the member STRLEN.O from the LIB.A library.

10. To create a compressed document library from multiple shared modules created with the LD command, enter:

Ar-r-v libshr.a shrsub.o shrsub2.o shrsub3.o ...

This command creates a compressed document library named LIBSHR.A from a shared module named SHRSUB.O, SHRSUB2.O, SHRSUB3.O, and so on. To compile and link the main program that uses LIBSHR.A to compress the document library, use the following command:

Cc-o Main MAIN.C-L/U/SHAREDLIB-LSHR

The main program is now executable. Any symbols referenced by the main program (contained in the LIBSHR.A compressed document library) have been flagged for latency resolution. The-l flag specifies that these symbols should be searched in the LIBSHR.A library.

11. To list the contents of the LIB.A (ignoring any 32-bit target files), enter:

Ar-x64-t-V LIB.A

12. To extract all 32-bit target files from LIB.A, enter:

Ar-x32-x LIB.A

13. To list all files in the LIB.A, whether 32-bit, 64-bit, or non-object, enter:

Ar-x32_64-t-V LIB.A

AR command Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.