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++ > Problems compiling GBA C++ code with MSVC++ GBA app wizard

#18426 - [Titan] - Thu Mar 25, 2004 10:03 pm

I've been trying to get devkitadv to compile my small c++ program for a couple of hours now, using MSVC++ 6. I'm using the app wizard (which works just fine for C programs) but I can't get one damn linking error fixed properly.

when I try to compile the following:
Code:
int main()
{
     while(1);
     return 0;
}

I get the error: undefined reference to '__gccmain'
this error is thrown by ld (the linker). I use the linkscript generated by the wizard, and already came to the conclusion that _gccmain is nowhere to be found.
If I put the line __gccmain = 0x8000000; in the linkscript, then the whole thing will compile without any errors (duh) but it doesn't seem to work properly. Then again, I don't know the actual address of __gccmain.

Does anyone know how to solve this problem? I can upload a rar file with the cpp, mak, linkscript, dsw, dsp and crt0.s file if that helps ^_^

#18434 - Lupin - Thu Mar 25, 2004 11:16 pm

I am not sure, but why don't you try this:

Code:

int __gccmain()
{
     while(1);
     return 0;
}


But well, don't expect too much from that code :P

Btw, you can also define the main function as void and save the return (i think you know that, but you waste 2/4 bytes with your return :P)
_________________
Team Pokeme
My blog and PM ASM tutorials

#18436 - [Titan] - Thu Mar 25, 2004 11:20 pm

that won't work, since I then get an error "undefined reference to main". I actually just solved it, and your suggestion was very close. Adding the line "__gccmain = main;" to the linkscript file was the solution ^_^ Everything seems to work fine now, but thanks for the kick in the right direction anyway :P