Could not find crtn.o by linking 32-bit code on a 64-bit system

I am trying to build 32-bit code using NASM and GCC on a 64-bit system. I use the following two commands

nasm -f elf32 -g -F stabs coc.asm gcc -m32 -o coc coc.o 

NASM seems to be doing well, but LD complains:

 /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 am running Ubuntu 11.10 and I have checked and I am sure that libc is installed.

+7
gcc nasm 64bit ld
Mar 21 2018-12-21T00:
source share
3 answers

You do not collect, but bind an executable file that needs OS startup files.

It seems you do not have gcc-*-multilib that contains the necessary files: http://packages.ubuntu.com/oneiric/amd64/gcc-4.6-multilib/filelist

+10
Mar 21 2018-12-12T00:
source share

You need to install gcc-multilib to get the proper 32-bit lib library

+2
Mar 21 2018-12-12T00:
source share

I had a very similar problem on ubuntu 11.10. Check out my question about this . What helped me linked crt*.o with /lib/ . After that, I had no other problems with this problem. A little more, but for me he solved the problem.

0
Mar 21 2018-12-12T00:
source share



All Articles