gccx86cross-compilingarch

Unable to run i386-elf-gcc


When installing i386-elf-gcc using aur. Install goes smoothly and no errors when I build. I added /usr/local/i386elfgcc/bin to my path and I am able to run the command. When I run a simple command such as i386-elf-gcc -g "kernel.cpp" -o "kernel.o", I am getting errors:

/usr/local/i386elfgcc/lib/gcc/i386-elf/10.2.0/../../../../i386-elf/bin/ld: cannot find crt0.o: No such file or directory
/usr/local/i386elfgcc/lib/gcc/i386-elf/10.2.0/../../../../i386-elf/bin/ld: cannot find -lg
/usr/local/i386elfgcc/lib/gcc/i386-elf/10.2.0/../../../../i386-elf/bin/ld: cannot find -lc

Reinstalling has not worked. What can I do to fix this? I am using Arch.


Solution

  • The original command was i386-elf-gcc -ffreestanding -m32 -g "kernel.cpp" -o "kernel.o" I needed to add -nostdlib
    Final command: i386-elf-gcc -nostdlib -ffreestanding -m32 -g "kernel.cpp" -o "kernel.o"