9

I'm attempting to assemble some 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 appears to do fine, 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'm running Ubuntu 11.10, and I checked and I'm pretty sure libc is installed.

  • 1
    possible duplicate of [Compiling problems: cannot find crt1.o](http://stackoverflow.com/questions/6329887/compiling-problems-cannot-find-crt1-o) – user2284570 Jul 17 '14 at 02:07

3 Answers3

11

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

rubenvb
  • 74,642
  • 33
  • 187
  • 332
2

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

x539
  • 1,006
  • 6
  • 16
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.

Community
  • 1
  • 1
LiKao
  • 10,408
  • 6
  • 53
  • 91