I'm attempting to assemble some 32-bit code using NASM and GCC on a 64-bit system. I use the following two commands
我正在嘗試在64位系統上使用NASM和GCC來組裝一些32位的代碼。我使用以下兩個命令
nasm -f elf32 -g -F stabs coc.asm
gcc -m32 -o coc coc.o
NASM appears to do fine, but LD complains:
NASM似乎做得很好,但是LD抱怨道:
/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.1/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.1/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.1/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.1/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
I'm running Ubuntu 11.10, and I checked and I'm pretty sure libc is installed.
我正在運行Ubuntu 11.10,我檢查了一下,我很確定libc已經安裝好了。
3 个解决方案
#1
10
You are not assembling, but linking an executable, which needs OS startup files.
您不是在組裝,而是鏈接可執行文件,這需要操作系統啟動文件。
It seems you don't have gcc-*-multilib installed, which contains the necessary files: http://packages.ubuntu.com/oneiric/amd64/gcc-4.6-multilib/filelist
似乎您沒有安裝gcc-*-multilib,它包含必要的文件:http://packages.ubuntu.com/oneiric/amd64/gcc-4.6-multilib/filelist
#2
2
You need to install gcc-multilib to get the proper 32-Bit lib
您需要安裝gcc-multilib以獲得適當的32位庫
#3
0
I had a very similar problem on ubuntu 11.10. See my question on SO about this. What helped for me, was linking the crt*.o to /lib/. After that I never had other problems with this issue. A bit more of a cludge, but for me it solved the problems.
我在ubuntu 11.10上遇到了一個非常相似的問題。看看我的問題。對我有幫助的是連接crt*。o /lib/.之后,我再也沒有遇到過這個問題。有點混亂,但對我來說,它解決了問題。