{
    "content": [
        {
            "type": "text",
            "text": "# ar (man)\n\n## NAME\n\nar - create, modify, and extract from archives\n\n## SYNOPSIS\n\nar [-X3264] [-]p[mod] [--plugin name] [--target bfdname] [--output dirname]\n[--record-libdeps libdeps] [--thin] [relpos] [count] archive [member...]\n\n## DESCRIPTION\n\nThe GNU ar program creates, modifies, and extracts from archives.  An archive is a single\nfile holding a collection of other files in a structure that makes it possible to retrieve\nthe original individual files (called members of the archive).\n\n## TLDR\n\n> Create, modify, and extract from Unix archives. Typically used for static libraries (`.a`) and Debian packages (`.deb`).\n\n- E[x]tract all members from an archive:\n  `ar x {{path/to/file.a}}`\n- Lis[t] contents in a specific archive:\n  `ar t {{path/to/file.ar}}`\n- [r]eplace or add specific files to an archive:\n  `ar r {{path/to/file.deb}} {{path/to/debian-binary path/to/control.tar.gz path/to/data.tar.xz ...}}`\n- In[s]ert an object file index (equivalent to using `ranlib`):\n  `ar s {{path/to/file.a}}`\n- Create an archive with specific files and an accompanying object file index:\n  `ar rs {{path/to/file.a}} {{path/to/file1.o path/to/file2.o ...}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (4 subsections)\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "ar",
        "section": "",
        "mode": "man",
        "summary": "ar - create, modify, and extract from archives",
        "synopsis": "ar [-X3264] [-]p[mod] [--plugin name] [--target bfdname] [--output dirname]\n[--record-libdeps libdeps] [--thin] [relpos] [count] archive [member...]",
        "tldr_summary": "Create, modify, and extract from Unix archives. Typically used for static libraries (`.a`) and Debian packages (`.deb`).",
        "tldr_examples": [
            {
                "description": "E[x]tract all members from an archive",
                "command": "ar x {{path/to/file.a}}"
            },
            {
                "description": "Lis[t] contents in a specific archive",
                "command": "ar t {{path/to/file.ar}}"
            },
            {
                "description": "[r]eplace or add specific files to an archive",
                "command": "ar r {{path/to/file.deb}} {{path/to/debian-binary path/to/control.tar.gz path/to/data.tar.xz ...}}"
            },
            {
                "description": "In[s]ert an object file index (equivalent to using `ranlib`)",
                "command": "ar s {{path/to/file.a}}"
            },
            {
                "description": "Create an archive with specific files and an accompanying object file index",
                "command": "ar rs {{path/to/file.a}} {{path/to/file1.o path/to/file2.o ...}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": "--help",
                "arg": null,
                "description": "Displays the list of command-line options supported by ar and then exits."
            },
            {
                "flag": "",
                "long": "--version",
                "arg": null,
                "description": "Displays the version information of ar and then exits."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "ar ignores an initial option spelled -X3264, for compatibility with AIX. The behaviour produced by this option is the default for GNU ar. ar does not support any of the other -X options; in particular, it does not support -X32 which is the default for AIX ar. --plugin name The optional command-line switch --plugin name causes ar to load the plugin called name which adds support for more file formats, including object files with link-time optimization information. This option is only available if the toolchain has been built with plugin support enabled. If --plugin is not provided, but plugin support has been enabled then ar iterates over the files in ${libdir}/bfd-plugins in alphabetic order and the first plugin that claims the object in question is used. Please note that this plugin search directory is not the one used by ld's -plugin option. In order to make ar use the linker plugin it must be copied into the ${libdir}/bfd-plugins directory. For GCC based compilations the linker plugin is called libltoplugin.so.0.0.0. For Clang based compilations it is called LLVMgold.so. The GCC plugin is always backwards compatible with earlier versions, so it is sufficient to just copy the newest one. --target target The optional command-line switch --target bfdname specifies that the archive members are in an object code format different from your system's default format. See --output dirname The --output option can be used to specify a path to a directory into which archive members should be extracted. If this option is not specified then the current directory will be used. Note - although the presence of this option does imply a x extraction operation that option must still be included on the command line. --record-libdeps libdeps The --record-libdeps option is identical to the l modifier, just handled in long form."
            },
            {
                "flag": "",
                "long": "--thin",
                "arg": null,
                "description": "Make the specified archive a thin archive. If it already exists and is a regular archive, the existing members must be present in the same directory as archive. @file Read command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed. Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The file may itself contain additional @file options; any such options will be processed recursively."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "nm",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/nm/1/json"
            },
            {
                "name": "ranlib",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ranlib/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 47,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 178,
                "subsections": [
                    {
                        "name": "--help",
                        "lines": 2,
                        "long": "--help"
                    },
                    {
                        "name": "--version",
                        "lines": 2,
                        "long": "--version"
                    },
                    {
                        "name": "-X32_64",
                        "lines": 38
                    },
                    {
                        "name": "--thin",
                        "lines": 14,
                        "long": "--thin"
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 9,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ar - create, modify, and extract from archives\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "ar [-X3264] [-]p[mod] [--plugin name] [--target bfdname] [--output dirname]\n[--record-libdeps libdeps] [--thin] [relpos] [count] archive [member...]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The GNU ar program creates, modifies, and extracts from archives.  An archive is a single\nfile holding a collection of other files in a structure that makes it possible to retrieve\nthe original individual files (called members of the archive).\n\nThe original files' contents, mode (permissions), timestamp, owner, and group are preserved\nin the archive, and can be restored on extraction.\n\nGNU ar can maintain archives whose members have names of any length; however, depending on\nhow ar is configured on your system, a limit on member-name length may be imposed for\ncompatibility with archive formats maintained with other tools.  If it exists, the limit is\noften 15 characters (typical of formats related to a.out) or 16 characters (typical of\nformats related to coff).\n\nar is considered a binary utility because archives of this sort are most often used as\nlibraries holding commonly needed subroutines.  Since libraries often will depend on other\nlibraries, ar can also record the dependencies of a library when the --record-libdeps option\nis specified.\n\nar creates an index to the symbols defined in relocatable object modules in the archive when\nyou specify the modifier s.  Once created, this index is updated in the archive whenever ar\nmakes a change to its contents (save for the q update operation).  An archive with such an\nindex speeds up linking to the library, and allows routines in the library to call each other\nwithout regard to their placement in the archive.\n\nYou may use nm -s or nm --print-armap to list this index table.  If an archive lacks the\ntable, another form of ar called ranlib can be used to add just the table.\n\nGNU ar can optionally create a thin archive, which contains a symbol index and references to\nthe original copies of the member files of the archive.  This is useful for building\nlibraries for use within a local build tree, where the relocatable objects are expected to\nremain available, and copying the contents of each object would only waste time and space.\n\nAn archive can either be thin or it can be normal.  It cannot be both at the same time.  Once\nan archive is created its format cannot be changed without first deleting it and then\ncreating a new archive in its place.\n\nThin archives are also flattened, so that adding one thin archive to another thin archive\ndoes not nest it, as would happen with a normal archive.  Instead the elements of the first\narchive are added individually to the second archive.\n\nThe paths to the elements of the archive are stored relative to the archive itself.\n\nGNU ar is designed to be compatible with two different facilities.  You can control its\nactivity using command-line options, like the different varieties of ar on Unix systems; or,\nif you specify the single command-line option -M, you can control it with a script supplied\nvia standard input, like the MRI \"librarian\" program.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "GNU ar allows you to mix the operation code p and modifier flags mod in any order, within the\nfirst command-line argument.\n\nIf you wish, you may begin the first command-line argument with a dash.\n\nThe p keyletter specifies what operation to execute; it may be any of the following, but you\nmust specify only one of them:\n\nd   Delete  modules  from  the  archive.   Specify  the  names  of  modules  to be deleted as\nmember...; the archive is untouched if you specify no files to delete.\n\nIf you specify the v modifier, ar lists each module as it is deleted.\n\nm   Use this operation to move members in an archive.\n\nThe ordering of members in an archive can make a difference in how  programs  are  linked\nusing the library, if a symbol is defined in more than one member.\n\nIf no modifiers are used with \"m\", any members you name in the member arguments are moved\nto  the  end  of  the  archive;  you  can  use the a, b, or i modifiers to move them to a\nspecified place instead.\n\np   Print the specified members of the archive, to  the  standard  output  file.   If  the  v\nmodifier  is  specified,  show  the  member  name before copying its contents to standard\noutput.\n\nIf you specify no member arguments, all the files in the archive are printed.\n\nq   Quick append; Historically, add the files  member...  to  the  end  of  archive,  without\nchecking for replacement.\n\nThe  modifiers a, b, and i do not affect this operation; new members are always placed at\nthe end of the archive.\n\nThe modifier v makes ar list each file as it is appended.\n\nSince the point of this operation is speed, implementations of ar have the option of  not\nupdating  the  archive's  symbol table if one exists.  Too many different systems however\nassume that symbol tables are always up-to-date, so GNU ar will rebuild  the  table  even\nwith a quick append.\n\nNote - GNU ar treats the command qs as a synonym for r - replacing already existing files\nin the archive and appending new ones at the end.\n\nr   Insert the files member... into archive (with replacement). This operation differs from q\nin  that  any  previously  existing  members are deleted if their names match those being\nadded.\n\nIf one of the files named in member... does not exist, ar displays an error message,  and\nleaves undisturbed any existing members of the archive matching that name.\n\nBy  default,  new  members  are  added at the end of the file; but you may use one of the\nmodifiers a, b, or i to request placement relative to some existing member.\n\nThe modifier v used with this operation elicits a line of output for each file  inserted,\nalong  with  one  of the letters a or r to indicate whether the file was appended (no old\nmember deleted) or replaced.\n\ns   Add an index to the archive, or update it if it already exists.  Note this command is  an\nexception to the rule that there can only be one command letter, as it is possible to use\nit as either a command or a modifier.  In either case it does the same thing.\n\nt   Display  a  table  listing  the  contents  of  archive,  or  those of the files listed in\nmember... that are present in the archive.  Normally only the member name is  shown,  but\nif  the  modifier  O  is  specified,  then the corresponding offset of the member is also\ndisplayed.  Finally, in order to see the modes (permissions),  timestamp,  owner,  group,\nand size the v modifier should be included.\n\nIf you do not specify a member, all files in the archive are listed.\n\nIf  there is more than one file with the same name (say, fie) in an archive (say b.a), ar\nt b.a fie lists only the first instance; to see them all, you must  ask  for  a  complete\nlisting---in our example, ar t b.a.\n\nx   Extract  members  (named  member) from the archive.  You can use the v modifier with this\noperation, to request that ar list each name as it extracts it.\n\nIf you do not specify a member, all files in the archive are extracted.\n\nFiles cannot be extracted from a thin archive, and there are restrictions  on  extracting\nfrom  archives  created with P: The paths must not be absolute, may not contain \"..\", and\nany subdirectories in the paths must exist.  If it is desired to avoid these restrictions\nthen used the --output option to specify an output directory.\n\nA number of modifiers (mod) may immediately follow the p keyletter, to specify variations  on\nan operation's behavior:\n\na   Add  new  files  after an existing member of the archive.  If you use the modifier a, the\nname of an existing archive member must be present as the  relpos  argument,  before  the\narchive specification.\n\nb   Add  new  files before an existing member of the archive.  If you use the modifier b, the\nname of an existing archive member must be present as the  relpos  argument,  before  the\narchive specification.  (same as i).\n\nc   Create  the  archive.   The specified archive is always created if it did not exist, when\nyou request an update.  But a warning is issued unless you specify in  advance  that  you\nexpect to create it, by using this modifier.\n\nD   Operate  in  deterministic  mode.   When  adding files and the archive index use zero for\nUIDs, GIDs, timestamps, and use consistent file modes for all files.  When this option is\nused, if ar is used with identical options and identical input files, multiple runs  will\ncreate  identical output files regardless of the input files' owners, groups, file modes,\nor modification times.\n\nIf binutils was configured with --enable-deterministic-archives, then this mode is on  by\ndefault.  It can be disabled with the U modifier, below.\n\nf   Truncate  names  in  the  archive.  GNU ar will normally permit file names of any length.\nThis will cause it to create archives which are not compatible with the native ar program\non some systems.  If this is a concern, the f modifier may be used to truncate file names\nwhen putting them in the archive.\n\ni   Insert new files before an existing member of the archive.  If you use  the  modifier  i,\nthe name of an existing archive member must be present as the relpos argument, before the\narchive specification.  (same as b).\n\nl   Specify  dependencies  of  this  library.   The dependencies must immediately follow this\noption character, must use the same syntax as  the  linker  command  line,  and  must  be\nspecified  within  a  single  argument.  I.e., if multiple items are needed, they must be\nquoted to form a single command line argument.  For example L \"-L/usr/local/lib  -lmydep1\n-lmydep2\"\n\nN   Uses the count parameter.  This is used if there are multiple entries in the archive with\nthe same name.  Extract or delete instance count of the given name from the archive.\n\no   Preserve  the original dates of members when extracting them.  If you do not specify this\nmodifier, files extracted from the archive are stamped with the time of extraction.\n\nO   Display member offsets inside the archive. Use together with the t option.\n\nP   Use the full path name when matching or storing names in the archive.   Archives  created\nwith full path names are not POSIX compliant, and thus may not work with tools other than\nup  to  date  GNU tools.  Modifying such archives with GNU ar without using P will remove\nthe full path names unless the archive is a thin archive.  Note that P may be useful when\nadding files to a thin archive since r without P ignores the  path  when  choosing  which\nelement to replace.  Thus\n\nar rcST archive.a subdir/file1 subdir/file2 file1\n\nwill  result  in  the  first  \"subdir/file1\" being replaced with \"file1\" from the current\ndirectory.  Adding P will prevent this replacement.\n\ns   Write an object-file index into the archive, or update an existing one, even if no  other\nchange is made to the archive.  You may use this modifier flag either with any operation,\nor alone.  Running ar s on an archive is equivalent to running ranlib on it.\n\nS   Do  not  generate an archive symbol table.  This can speed up building a large library in\nseveral steps.  The resulting archive can not be used with the linker.  In order to build\na symbol table, you must omit the S modifier on the last execution of ar, or you must run\nranlib on the archive.\n\nT   Deprecated alias for --thin.  T is not recommended because in many ar  implementations  T\nhas a different meaning, as specified by X/Open System Interface.\n\nu   Normally, ar r... inserts all files listed into the archive.  If you would like to insert\nonly  those of the files you list that are newer than existing members of the same names,\nuse this modifier.  The u modifier is allowed only for the  operation  r  (replace).   In\nparticular,  the  combination qu is not allowed, since checking the timestamps would lose\nany speed advantage from the operation q.\n\nNote - if an archive has been created in a deterministic manner, eg via the use of the  D\nmodifier, then replacement will always happen and the u modifier will be ineffective.\n\nU   Do  not  operate  in  deterministic  mode.  This is the inverse of the D modifier, above:\nadded files and the archive index will get their actual UID,  GID,  timestamp,  and  file\nmode values.\n\nThis is the default unless binutils was configured with --enable-deterministic-archives.\n\nv   This  modifier  requests  the  verbose  version of an operation.  Many operations display\nadditional information, such as filenames processed, when the modifier v is appended.\n\nV   This modifier shows the version number of ar.\n\nThe ar program also supports some  command-line  options  which  are  neither  modifiers  nor\nactions, but which do change its behaviour in specific ways:\n",
                "subsections": [
                    {
                        "name": "--help",
                        "content": "Displays the list of command-line options supported by ar and then exits.\n",
                        "long": "--help"
                    },
                    {
                        "name": "--version",
                        "content": "Displays the version information of ar and then exits.\n",
                        "long": "--version"
                    },
                    {
                        "name": "-X32_64",
                        "content": "ar  ignores an initial option spelled -X3264, for compatibility with AIX.  The behaviour\nproduced by this option is the default for GNU ar.  ar does not support any of the  other\n-X options; in particular, it does not support -X32 which is the default for AIX ar.\n\n--plugin name\nThe  optional  command-line switch --plugin name causes ar to load the plugin called name\nwhich adds  support  for  more  file  formats,  including  object  files  with  link-time\noptimization information.\n\nThis  option  is  only  available  if  the  toolchain  has been built with plugin support\nenabled.\n\nIf --plugin is not provided, but plugin support has been enabled then  ar  iterates  over\nthe  files  in ${libdir}/bfd-plugins in alphabetic order and the first plugin that claims\nthe object in question is used.\n\nPlease note that this plugin search directory is not the one used by ld's -plugin option.\nIn  order  to  make  ar  use  the   linker  plugin   it   must   be   copied   into   the\n${libdir}/bfd-plugins  directory.  For GCC based compilations the linker plugin is called\nlibltoplugin.so.0.0.0.  For Clang based compilations it is called LLVMgold.so.  The  GCC\nplugin  is always backwards compatible with earlier versions, so it is sufficient to just\ncopy the newest one.\n\n--target target\nThe optional command-line switch --target bfdname specifies that the archive members  are\nin an object code format different from your system's default format.  See\n\n--output dirname\nThe  --output  option  can  be  used  to specify a path to a directory into which archive\nmembers should be extracted.  If this option is not specified then the current  directory\nwill be used.\n\nNote  -  although  the  presence  of this option does imply a x extraction operation that\noption must still be included on the command line.\n\n--record-libdeps libdeps\nThe --record-libdeps option is identical to the l modifier, just handled in long form.\n"
                    },
                    {
                        "name": "--thin",
                        "content": "Make the specified archive a thin archive.   If  it  already  exists  and  is  a  regular\narchive, the existing members must be present in the same directory as archive.\n\n@file\nRead  command-line  options  from  file.   The  options read are inserted in place of the\noriginal @file option.  If file does not exist, or cannot be read, then the  option  will\nbe treated literally, and not removed.\n\nOptions  in  file are separated by whitespace.  A whitespace character may be included in\nan option by surrounding the entire option  in  either  single  or  double  quotes.   Any\ncharacter  (including  a  backslash)  may  be  included  by prefixing the character to be\nincluded with a backslash.  The file may itself contain  additional  @file  options;  any\nsuch options will be processed recursively.\n",
                        "long": "--thin"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "nm(1), ranlib(1), and the Info entries for binutils.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 1991-2024 Free Software Foundation, Inc.\n\nPermission  is granted to copy, distribute and/or modify this document under the terms of the\nGNU Free Documentation License, Version 1.3 or  any  later  version  published  by  the  Free\nSoftware Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-\nCover  Texts.   A  copy  of  the  license  is  included  in  the  section  entitled \"GNU Free\nDocumentation License\".\n\nbinutils-2.42                                2026-02-09                                        AR(1)",
                "subsections": []
            }
        }
    }
}