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 problem

#38484 - serf - Mon Mar 28, 2005 11:45 am

Ok, I'm trying to get started on OS X here using libgba and devkitARM. I've managed to compile and run a quick little program that writes out a bunch of pixels to the framebuffer and loops -- no problem there. But now I'm trying to call functions in libgba, and every single time I get the following linker error:

Code:

dynamic-oit-vapornet-c-178:~/Projects/devkitARMtest matt$ make
/Users/matt/devkitARM_r11_OSX/bin/arm-elf-gcc -mthumb-interwork -c test.c
/Users/matt/devkitARM_r11_OSX/bin/arm-elf-gcc -specs=gba.specs -lgba -mthumb-interwork test.o -o test.elf
test.o(.text+0x104): In function `main':
: undefined reference to `Div'
collect2: ld returned 1 exit status
make: *** [build] Error 1


I know that the header files are found correctly: gcc complains if Div gets an incorrect number of arguments. I think ld is finding libgba.a OK: if I change -lgba to -lfake, it complains about not being able to find the library.

I'm using the precompiled version of devkitARM r11 for OS X from their Sourceforge site, and libgba 20050313 from the same source. I've tried both the version of libgba.a in the binary distribution and one that I built from source using devkitARM -- neither worked (same error as above).

Any thoughts on how I might be able to fix this?

#38577 - wintermute - Tue Mar 29, 2005 7:08 am

where are you putting libgba?

It sounds like you have another libgba in your lib path somewhere which doesn't have Div defined.

#38585 - serf - Tue Mar 29, 2005 9:50 am

find tells me that I have only two files named libgba.a on my hard drive -- one in the directory where I compiled my copy, and one in gcc's library search path (a copy of the one I compiled -- I put it there). Also, I've tried a few functions from the header files besides Div -- FadeToGrayscale, InitInterrupt, ObjAffineSet -- and none are found, so I doubt I'm simply finding a different version of the library.

Am I overlooking something? Or does my problem most likely lie elsewhere?

Thanks again ... I'm really stumped here.

#38684 - serf - Wed Mar 30, 2005 8:33 am

Well, I'm a moron.

Code:
arm-elf-gcc -g -mthumb -mthumb-interwork -Wl -specs=gba.specs -lgba test.o -o test.elf

is very very bad, but
Code:
arm-elf-gcc -g -mthumb -mthumb-interwork -Wl -specs=gba.specs test.o -lgba -o test.elf

is just fine.