3 回答

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超5個(gè)贊
傳遞-relocatable或-r以ld將創(chuàng)建一個(gè)對(duì)象,它是適合作為輸入ld。
$ ld -relocatable a.o b.o -o c.o
$ gcc c.o other.o -o executable
$ ./executable
生成的文件與原始.o文件的類型相同。
$ file a.o
a.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
$ file c.o
c.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個(gè)贊
如果要?jiǎng)?chuàng)建兩個(gè)或更多.o文件的存檔(即靜態(tài)庫(kù)),請(qǐng)使用以下ar命令:
ar rvs mylib.a file1.o file2.o

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超8個(gè)贊
警告: --relocatable
似乎不太方便攜帶。Android NDK隨附的ld只能識(shí)別-relocatable
。如果您需要便攜性,請(qǐng)堅(jiān)持使用-r
。
- 3 回答
- 0 關(guān)注
- 1530 瀏覽
添加回答
舉報(bào)