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.

Coding > link error

#22435 - auchzahgen - Mon Jun 21, 2004 8:07 am

Hi, I'm trying to write some C++ code for the GBA using devkitadv-r5-beta-3 but I keep getting link errors when I build it. The code I'm compiling is:

Code:
int main()
{
   int *test = new int;
   delete test;

   return 0;
}


and the error's I'm getting are:

ld: warning: cannot find entry symbol _start; defaulting to 08000000
test.o: In function `main':
test.o(.text+0x14): undefined reference to `operator new(unsigned long)'
test.o(.text+0x20): undefined reference to `operator delete(void*)'

The commands I'm using to compile are:
gcc -c test.cpp
ld -o test.elf test.o

I'm guessing that the linker isn't finding the proper libraries to link with. I don't know how to fix this though. Can somebody give me a hand?

Thanks,
-auchzahgen

#22436 - Cearn - Mon Jun 21, 2004 8:48 am

If you try to link using ld you have to specify all the boot-up files and libraries and paths manually. Unless you like pain, try using gcc for linking instead. Better yet, use g++ for compiling and linking since that's the real C++ compiler.

#22437 - auchzahgen - Mon Jun 21, 2004 9:20 am

I figured out what it was. I linked using gcc and linked in the stdc++ library. I could have also just used g++ to link my .o files like Cearn said.

-auchzahgen