Gcc collect2: fatal error: cannot find 'ld'

XXO2 picture XXO2 · Mar 13, 2016 · Viewed 21.5k times · Source

I'm going through the tutorial on making an OS on http://wiki.osdev.org/Bare_Bones. When I try to link boot.o and kernel.o using this command: i686-elf-gcc -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc , I just get this error:

collect2: fatal error: cannot find 'ld'
compilation terminated.

I just installed fresh Ubuntu 15.10 that with gcc-5.2.1 and binutils-2.25.1 . I have searched the internet for answers but nothing helped.

Answer

Lord Boval picture Lord Boval · Oct 29, 2019

I also got once the same error during a pentest while I was trying to compile my exploit on the victim server.

In my case, the directory where the "ld" program was located had not been defined in the PATH environment variable, so I simply added it.

eg. export PATH=$PATH:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin