| View previous topic :: View next topic |
| Author |
Message |
mase
Joined: 21 Aug 2009 Posts: 23
|
Posted: Mon Aug 24, 2009 12:23 am Post subject: undefined reference to `main' |
|
|
Hello!
What does this error mean? How can I solve this? It appears, when
compiling openttd.
| Code: | /usr/share/psp-dev/bin/../lib/gcc/psp/4.3.2/../../../../psp/lib/crt0.o: In function `_main':
/tmp/psptoolchain/build/pspsdk/src/startup/crt0.c:86: undefined reference to `main'
collect2: ld returned 1 exit status
|
_________________ May the force be with us! |
|
| Back to top |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Mon Aug 24, 2009 1:07 am Post subject: |
|
|
It means the linker can't find any main function. _________________
| Code: | int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
} |
|
|
| Back to top |
|
 |
mase
Joined: 21 Aug 2009 Posts: 23
|
Posted: Mon Aug 24, 2009 1:35 am Post subject: |
|
|
The only main function is
| Code: | | int ttd_main(int argc, char *argv[]) | in openttd.cpp.
Even if I rename ttd_main to main, I get the same error.
But it compiles fine for Linux.
But it is an SDL application. So if I link SDLmain, it should work, but
it doesn't. _________________ May the force be with us! |
|
| Back to top |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Mon Aug 24, 2009 3:30 am Post subject: |
|
|
| mase wrote: | The only main function is
| Code: | | int ttd_main(int argc, char *argv[]) | in openttd.cpp.
Even if I rename ttd_main to main, I get the same error.
But it compiles fine for Linux.
But it is an SDL application. So if I link SDLmain, it should work, but
it doesn't. |
Don't use SDL. It's verry slow. Try oslib as graphics engine. _________________
| Code: | int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
} |
|
|
| Back to top |
|
 |
mase
Joined: 21 Aug 2009 Posts: 23
|
Posted: Mon Aug 24, 2009 4:04 am Post subject: |
|
|
I must use SDL, because it is not my code.
I added -l SDLmain -lSDL in build.mak of the SDK. Now I get
| Code: | psp-gcc -I. -I/usr/share/psp-dev/psp/sdk/include -D_PSP_FW_VERSION=150 -L. -L/usr/share/psp-dev/psp/sdk/lib -lSDLmain -lSDL -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o .elf
/usr/share/psp-dev/bin/../lib/gcc/psp/4.3.2/../../../../psp/lib/libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:86: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
|
_________________ May the force be with us! |
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Mon Aug 24, 2009 4:19 am Post subject: |
|
|
if you use SDL_MAIN it declare for you a main() function but within this function
a call has been made to sdl_main(int argc,char **argv) to init you SDL program
so it is normal that you've got a undefined reference to `SDL_main'n if you don't provide a sdl_main function
int main(int argc, char *argv[])
{
pspDebugScreenInit();
sdl_psp_setup_callbacks();
/* Register sceKernelExitGame() to be called when we exit */
atexit(sceKernelExitGame);
(void)SDL_main(argc, argv);
return 0;
} |
|
| Back to top |
|
 |
mase
Joined: 21 Aug 2009 Posts: 23
|
Posted: Mon Aug 24, 2009 4:45 am Post subject: |
|
|
The code does not provide such a function. But the code, that compiles,
doesn't, too.
Maybe you could have a look on it.
The one I am working on is here:
http://www.openttd.org/en/
It is the version 0.7.2, which I configured
| Code: | | ./configure --os=psp --host=psp --with-sdl=/usr/share/psp-dev/psp/bin/sdl-config --with-allegro=/usr/share/psp-dev/psp/bin/psp-allegro-config --with-freetype=/usr/share/psp-dev/psp/bin/freetype-config |
The working one is here:
http://sourceforge.net/projects/openttd-psp
It is the version 0.5.3, which compiles and runs fine.
But as I said, both don't provide such a function. _________________ May the force be with us! |
|
| Back to top |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 64
|
Posted: Mon Aug 24, 2009 4:55 am Post subject: |
|
|
if you're using -lSDLmain
the you need to define SDL_main and use that as your main function _________________ Click ME! |
|
| Back to top |
|
 |
mase
Joined: 21 Aug 2009 Posts: 23
|
Posted: Mon Aug 24, 2009 5:08 am Post subject: |
|
|
Yes, but the working code doesn't provide a SDL_main function, too.
So how can it run? _________________ May the force be with us! |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Aug 24, 2009 6:02 am Post subject: |
|
|
| mase wrote: | Yes, but the working code doesn't provide a SDL_main function, too.
So how can it run? |
Buried in the makefile(s) somewhere is probably a define for SDL_main that sets it to ttd_main. |
|
| Back to top |
|
 |
mase
Joined: 21 Aug 2009 Posts: 23
|
Posted: Mon Aug 24, 2009 8:05 am Post subject: |
|
|
No, there isn't. Please check the code, if you don't believe me. _________________ May the force be with us! |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Aug 24, 2009 8:22 am Post subject: |
|
|
Okay, main() is in the platform specific code like os2.cpp. In os2.cpp you find:
| Code: | int CDECL main(int argc, char *argv[])
{
SetRandomSeed(time(NULL));
return ttd_main(argc, argv);
} |
Clearly, in your psp.cpp (or whatever you call the PSP platform specific file you made), you need the same thing. |
|
| Back to top |
|
 |
|