GP2X Dev-c++ Sdl Linker Error With Gp2xsdk


KZouLoN

Still Fresh
Joined
Aug 11, 2006
Messages
11
Hello, I am currently developing a simple 2 player chess program for the GP2X. It will also have an AI but it will be limited to random moves. I don't want to start with something too complicated.

I am using Dev-C++ from the file gp2xsdk_windows.zip and I compiled a couple of times for the GP2X without problems. Now I need to go back to using SDL in windows so I can ouput debuging hints with printf to fix bugs. In particular, checkmate isn't working, hehe.

I can compile almost every lazyfoo's SDL tutorial without errors. Here is the error I get when I compile my chess program :
C:\GP2XSDK\lib\libSDLmain.a(SDL_win32_main.o) In function `console_main':
[Linker error] undefined reference to `SDL_main'
C:\GP2XSDK\lib\libSDLmain.a(SDL_win32_main.o) ld returned 1 exit status
When I look at the compile log I get :
Compiler: win
Executing g++.exe...
g++.exe "C:\PROGRAMMATION\kzechecs\kzechecs.cpp" -o "C:\PROGRAMMATION\kzechecs\kzechecs.exe" -DWIN32 -Dmain=SDL_main -I"C:\GP2XSDK\include\GP2X" -I"C:\GP2XSDK\include\SDL" -I"C:\GP2XSDK\lib\gcc\mingw32\3.4.2\include" -I"C:\GP2XSDK\include\c++\3.4.2\backward" -I"C:\GP2XSDK\include\c++\3.4.2\mingw32" -I"C:\GP2XSDK\include\c++\3.4.2" -I"C:\GP2XSDK\include" -L"C:\GP2XSDK\lib" -lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_image -liconv -lgp2x
C:\GP2XSDK\lib/libSDLmain.a(SDL_win32_main.o): In function `console_main':
/home/hercules/public_cvs/SDL12/src/main/win32/SDL_win32_main.c:249: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
Execution terminated

It says the error is in function console_main. This is not a function I created.

The compilter's parameters are:
-DWIN32 -Dmain=SDL_main
The linker's parameters are:
-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_image -liconv -lgp2x


Please help me out on this as I would really like to complete my first big project. :p
 
I can't see anything wrong, -Dmain=SDL_main should rename your main function to SDL_main, so it should be defined.

You might be interested to know that I am also working on a chess program but it is a front end for gnuchess (which provides the AI) using the the XBoard's chess engine protocol.
 
Ive found I had to have


before my *.o's then followed by -lSDL_image -lSDLmain -lSDL

so -Dmain=SDL_main -mwindows -lmingw32 a.o b.o c.o d.o -lSDL_image -lSDLmain -lSDL

(thats when building the windows port of my code... i have diff response for building the gp2x side of my code)... but that fixed my error with sdl main...
 
After browsing the bloodshed.net forums I found a solution. I changed
Code:
int main ()
to
Code:
int main(int argc, char *argv[])
and now the problem is solved! Thanks anyways for the input guys.

By the way Parkydr, please don't complete your chess program as it will render my project absolete... Just kidding! It's nice to see the GP2X community being so active. :lol:
 
Back
Top