The ar command maintains the indexed libraries used by the linkage editor.
ar 命令可用于維護(hù) indexed libraries, indexed libraries通常被鏈接器使用, 用于和其它object文件進(jìn)行鏈接.
The ar command combines one or more named files into a single archive file written in ar archive format.
ar命令組合一個(gè)或者多個(gè)命名的文件到單個(gè)歸檔文件
In an ar command, you can specify any number of optional flags from the set cClosTv.
ar命令可以指定參數(shù)集cClosTv中的0或多個(gè).
You must specify one flag from the set of flags dhmopqrstwx.
ar命令必須指定參數(shù)集dhmopqrstwx中的1或多個(gè).
If you select the -m or -r flag, you may also specify a positioning flag (-a, -b, or -i);
如果你指定了-m or -r, 你也許需要指定(-a, -b, or -i)
for the -a, -b, or -i flags, you must also specify the name of a file within ArchiveFile (PositionName), immediately following the flag list and separated from it by a blank.
如果指定了 -a -b -i,你一定要指定一個(gè)在歸檔文件中的命名文件(即已經(jīng)歸檔的object文件名)
并且用空格分隔歸檔文件名和命名文件名.
//第一類
-m 移到一個(gè)已經(jīng)歸檔的object文件到某個(gè)位置.默認(rèn)為移動(dòng)到最后.你可以使用 -a -b -i 指定位置.
-a 移到一個(gè)已經(jīng)歸檔的object文件到指定object文件之后
-b 移到一個(gè)已經(jīng)歸檔的object文件到指定object文件之后
-i 移到一個(gè)已經(jīng)歸檔的object文件到指定object文件之后,和-b相同.
//第二類
-d 刪除一個(gè)已經(jīng)歸檔的object文件
-r 替換一個(gè)已經(jīng)歸檔的object文件.
如果不存在就加入, 你可以通過(guò)abi指定位置, 可以默認(rèn)加到最后.
-q 把一個(gè)object文件加到歸檔文件最后,如果你加入兩次,歸檔文件中就會(huì)存在兩次,它不會(huì)替換舊的.
//第三類
-c 壓制信息輸出
-v 把庫(kù)的詳細(xì)內(nèi)容輸出到標(biāo)準(zhǔn)輸出.
/*以下兩個(gè)不長(zhǎng)用*/
-C Prevents extracted files from replacing like-named files in the file system.
-T本用于把長(zhǎng)文件名截?cái)? 但已經(jīng)無(wú)用.
//第四類
-l 把此命令的臨時(shí)文件放到指定位置.
-x 拷貝命名文件夾到當(dāng)前目錄, 如果不指定, 它會(huì)拷貝所有文件到當(dāng)前目錄.
-z 在ar命令工作期間,使用臨時(shí)拷貝,而不是源庫(kù), 當(dāng)ar命令結(jié)束時(shí),使用臨時(shí)拷貝替換源庫(kù).
//第五類
-p
-h 更新時(shí)間
-t 把庫(kù)的內(nèi)容寫到標(biāo)準(zhǔn)輸出.
-w 顯示符號(hào)表, 每個(gè)符號(hào)都顯示所屬文件名
//第六類
-s 強(qiáng)制重新生成符號(hào)表.不論當(dāng)前的ar命令是否改變了歸檔文件.
-u 只拷貝最近更新的文件.
-X mode
指定ar 命令應(yīng)當(dāng)檢查的object 文件的類型,
32
64
32_64
默認(rèn)為32, 你也可能通過(guò)學(xué)習(xí)OBJECT_MODE環(huán)境變量來(lái)指定.
Usage: {}必選一個(gè) []可選.
ar [-X{32|64|32_64|d64|any}] [-clsvCT] [-g|o] {-h|p|t|x}
[--] Archive [File ...]
ar [-X{32|64|32_64|d64|any}] [-clsvCT] [-g|o] {-m|r[u]}
[{-a|b|i} {PositionName}] [--] Archive File ...
ar [-X{32|64|32_64|d64|any}] [-clsvCT] [-g|o] {-d|q}
[--] Archive File ...
ar [-X{32|64|32_64|d64|any}] [-clvCT] {-g|o|s|w} [--] Archive
ar -X64 -t libifms.a
顯示庫(kù)的內(nèi)容.like ls
ar -X64 -vt libifms.a
顯示庫(kù)的詳細(xì)內(nèi)容like ls-l
ar -X64 -w libifms.a string.o
顯示符號(hào)表.