我使用Ubuntu 12.04 64位機器上,我有這個簡單的C代碼:32位標準C庫
int b = 20;
int c = 10;
int main(int argc, char **argv) {
c = 50;
}
我試圖通過編寫它像使它與任何IA32的機器兼容這樣的:
unix> gcc -m32 code.c
,並得到這些錯誤:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
據我所知,這種情況正在發生,因爲我失去了32位ST andard C庫,所以鏈接器無法將我的代碼與標準C庫鏈接。
如何在64位機器上獲得所需的32位標準C?與-m32
apt-get install ia32-libs
此外,你應該編譯/鏈接:
可能重複[找不到crtn.o,在64位系統連接的32位代碼] (http://stackoverflow.com/questions/9807581/cannot-find-crtn-o-linking-32-bit-code-on-64-bit-system) – user2284570