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.

C/C++ > How to link with newlib using DevkitAdv?

#3978 - ZhouChang - Fri Mar 14, 2003 9:39 am

Hello all,
I am programing my GBA using Devkitadv tool chain.
I want to use sprintf,strcpy etc . Have these functions been implemented in newlib which coming from devkitadv? I want to link them into my gba file, How can i do that? Or where can i get a simple lib ?
Here is my Makefile:
Code:

AS = arm-agb-elf-as
LD = arm-agb-elf-ld
CC = arm-agb-elf-gcc
OBJDUMP = arm-agb-elf-objdump
CFLAGS = -Wall
ASFLAGS =
LDFLAGS = -nostartfiles -nostdlib -T lnkscript

OBJECTS = crt0.o startup.o arm.o util.o zxfont.o

all: t.gba

clean:
    rm -f *.o main.elf t.gba

t.gba: main.elf
    arm-agb-elf-objcopy -O binary main.elf t.gba

main.elf: ${OBJECTS}
    $(CC) $(LDFLAGS) -o main.elf ${OBJECTS} -lgcc
    $(OBJDUMP) -x main.elf > System.map

.c.o: $<
    $(CC) $(CFLAGS) -c -o $@ $<

.s.o: $<
    $(AS) $(ASFLAGS) -o $@ $<

#3996 - Touchstone - Sat Mar 15, 2003 12:16 am

Code:
main.elf: ${OBJECTS}
    $(CC) $(LDFLAGS) -o main.elf ${OBJECTS} -lgcc
    $(OBJDUMP) -x main.elf > System.map


The '-lgcc' tell the linker to add the file libgcc.a when linking. Note how the linker add the 'lib' prefix and '.a' suffix automatically to the library filename.
_________________
You can't beat our meat