gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Linker error: crt0.o not found

#63481 - SharQueDo - Tue Dec 13, 2005 3:20 pm

Hi. I'm new to GBADev. I downloaded and installed DevKitPro. I made a simple gba program, and this is my makefile:

Code:
PROJ=main
CC=arm-elf-gcc
OBJCOPY=arm-elf-objcopy

.PHONY: build
build:
   $(CC) -c -mthumb-interwork main.c
   $(CC) -o $(PROJ).elf main.o
   $(OBJCOPY) -O binary $(PROJ).elf $(PROJ).gba

.PHONY: clean
clean:
   @rm -rv *.gba *.elf *.o


When I try to make I get this output:

Code:
E:\zzMOO2\GBA Test>make
arm-elf-gcc -c -mthumb-interwork main.c
arm-elf-gcc -o main.elf main.o
c:\devkitpro\devkitarm\bin\..\lib\gcc\arm-elf\4.0.2\..\..\..\..\arm-elf\bin\ld.e
xe: crt0.o: No such file: No such file or directory
make: *** [build] Error 1


Help. :(

#63506 - Cearn - Tue Dec 13, 2005 8:41 pm

You need to add specs at the linking stage, either -specs=gba.specs, or -specs=gba_mb.specs for a multiboot game.

Code:
   $(CC) -specs=gba.specs -o $(PROJ).elf main.o

I'd also advise compiling as thumb code, instead of the default arm compilation: add -mthumb to the compiling and link flags. Also, optimisations might be nice, say -O2. Oh, and maybe use gbafix to fix the header if you ever want to run it on hardware.

Try this:
Code:
    $(CC) -O2 -mthumb -mthumb-interwork -c main.c
    $(CC) -mthumb -mthumb-interwork -specs=gba.specs -o $(PROJ).elf main.o
    $(OBJCOPY) -O binary $(PROJ).elf $(PROJ).gba
    gbafix $(PROJ).gba