GP2X Need Help Compiling For Windows


Gadget

Member
Joined
May 16, 2006
Messages
247
Hi,

I have been using CodeBlocks with the GP2X dev kit for several weeks now. Game is coming along nicely, but I need to cross compile for Windows to aid testing and development.

I have downloaded:-

SDL 1.2.11
SDL_image 1.2.5
SDL_mixer 1.2.7
SDL_ttf 2.0.8


I have the includes all set correctly I believe as I get no compilation errors now. I have also used compiler directives to comment out any non GP2X related code.

The problem I have now is linking... What am I missing here? There error shown is:-

Switching to target: default
Compiling: shell.cpp
Linking executable: C:\devkitGP2X\projects\Invaders\Invaders.exe
C:\Program Files\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe: cannot find -lSDL_gfx
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings


cannot find -lSDL_gfx

This leads me to think it cannot find the library for SDL_gfx? Is that part of the standard SDL?


If I remove the linker options (from the GP2X project settings), I get this:-

Linking executable: C:\devkitGP2X\projects\Invaders\Invaders.exe
.objs\shell.o:shell.cpp:(.text+0x1e9): undefined reference to `TTF_OpenFont'
.objs\shell.o:shell.cpp:(.text+0x1fe): undefined reference to `TTF_OpenFont'
.objs\shell.o:shell.cpp:(.text+0x273): undefined reference to `TTF_RenderText_Blended'
.objs\shell.o:shell.cpp:(.text+0x2d4): undefined reference to `TTF_RenderText_Blended'
.objs\shell.o:shell.cpp:(.text+0x3ab): undefined reference to `TTF_RenderText_Blended'
.objs\shell.o:shell.cpp:(.text+0x40c): undefined reference to `TTF_RenderText_Blended'
.objs\shell.o:shell.cpp:(.text+0x51e): undefined reference to `Mix_FreeChunk'
.objs\shell.o:shell.cpp:(.text+0x52b): undefined reference to `Mix_FreeChunk'
.objs\shell.o:shell.cpp:(.text+0x538): undefined reference to `Mix_FreeChunk'
.objs\shell.o:shell.cpp:(.text+0x545): undefined reference to `Mix_FreeChunk'
.objs\shell.o:shell.cpp:(.text+0x552): undefined reference to `Mix_FreeChunk'
.objs\shell.o:shell.cpp:(.text+0x55f): more undefined references to `Mix_FreeChunk' follow
.objs\shell.o:shell.cpp:(.text+0x56c): undefined reference to `Mix_FreeMusic'
.objs\shell.o:shell.cpp:(.text+0x579): undefined reference to `Mix_FreeMusic'
.objs\shell.o:shell.cpp:(.text+0x57e): undefined reference to `Mix_CloseAudio'
.objs\shell.o:shell.cpp:(.text+0x58b): undefined reference to `TTF_CloseFont'
.objs\shell.o:shell.cpp:(.text+0x598): undefined reference to `TTF_CloseFont'
.objs\shell.o:shell.cpp:(.text+0x59d): undefined reference to `TTF_Quit'
.objs\shell.o:shell.cpp:(.text+0xbc0): undefined reference to `Mix_Volume'
.objs\shell.o:shell.cpp:(.text+0xbcd): undefined reference to `Mix_VolumeMusic'
.objs\shell.o:shell.cpp:(.text+0xc06): undefined reference to `Mix_Volume'
.objs\shell.o:shell.cpp:(.text+0xc13): undefined reference to `Mix_VolumeMusic'
.objs\shell.o:shell.cpp:(.text+0x1015): undefined reference to `IMG_Load'
.objs\shell.o:shell.cpp:(.text+0x112c): undefined reference to `Mix_PlayChannelTimed'
.objs\shell.o:shell.cpp:(.text+0x1145): undefined reference to `Mix_SetPanning'
.objs\shell.o:shell.cpp:(.text+0x18e6): undefined reference to `Mix_PlayChannelTimed'
.objs\shell.o:shell.cpp:(.text+0x2313): undefined reference to `Mix_PlayMusic'
.objs\shell.o:shell.cpp:(.text+0x2f2b): undefined reference to `Mix_PlayChannelTimed'
.objs\shell.o:shell.cpp:(.text+0x31da): undefined reference to `Mix_PlayChannelTimed'
.objs\shell.o:shell.cpp:(.text+0x341b): undefined reference to `Mix_HaltMusic'
.objs\shell.o:shell.cpp:(.text+0x3452): undefined reference to `Mix_HaltMusic'
.objs\shell.o:shell.cpp:(.text+0x3468): undefined reference to `Mix_PlayMusic'
.objs\shell.o:shell.cpp:(.text+0x366d): undefined reference to `Mix_HaltMusic'
.objs\shell.o:shell.cpp:(.text+0x3683): undefined reference to `Mix_PlayMusic'
.objs\shell.o:shell.cpp:(.text+0x37ea): undefined reference to `Mix_PlayMusic'
.objs\shell.o:shell.cpp:(.text+0x415e): undefined reference to `Mix_HaltMusic'
.objs\shell.o:shell.cpp:(.text+0x47f8): undefined reference to `Mix_LoadWAV_RW'
.objs\shell.o:shell.cpp:(.text+0x4823): undefined reference to `Mix_LoadWAV_RW'
.objs\shell.o:shell.cpp:(.text+0x484e): undefined reference to `Mix_LoadWAV_RW'
.objs\shell.o:shell.cpp:(.text+0x4879): undefined reference to `Mix_LoadWAV_RW'
.objs\shell.o:shell.cpp:(.text+0x48a4): undefined reference to `Mix_LoadWAV_RW'
.objs\shell.o:shell.cpp:(.text+0x48cf): more undefined references to `Mix_LoadWAV_RW' follow
.objs\shell.o:shell.cpp:(.text+0x48e0): undefined reference to `Mix_LoadMUS'
.objs\shell.o:shell.cpp:(.text+0x48f1): undefined reference to `Mix_LoadMUS'
.objs\shell.o:shell.cpp:(.text+0x4be7): undefined reference to `TTF_Init'
.objs\shell.o:shell.cpp:(.text+0x4c0e): undefined reference to `Mix_OpenAudio'
.objs\shell.o:shell.cpp:(.text+0x4cae): undefined reference to `Mix_Volume'
.objs\shell.o:shell.cpp:(.text+0x4cbb): undefined reference to `Mix_VolumeMusic'
.objs\shell.o:shell.cpp:(.text+0x4cd1): undefined reference to `Mix_PlayMusic'
C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
 
I think what I really need here is a simple guide to setting up the compiler to produce an exe on Windows.

I have the includes (as far as I can see), but I am unsure what linker settings I need, and where on earth the .a / .o files, and whether I need them?

I come from a Delphi background, so it's no surprise...


EDIT: I can compile and run a new SDL Project, so SDL is setup correctly. It's something to do with the order of linking, but I have no clue what to replace this with:-

-static -lSDL_gfx -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng12 -lz -lSDL_mixer -lvorbisidec -lmikmod -lsmpeg -lSDL -lgcc -lm -lc -lexpat -lpthread
 
http://lazyfooproductions.com/SDL_tutorial...locks/index.php

Which libs are you using? The VC6 (.libs) or GCC compiled (.a). This is my current 'setup' using the pre compiled VC6 .lib files:
20zvjq1.png
 
Sorry if this is a stupid question, but where do i get the .a or .libs files? Do I need to produce these from the source??

EDIT: OK, looks like I need to create a MAKEFILE and then do a MAKE to build each file? Anyone got a shell that would work?
 
yaustar posted on Jul 26 2006 at 04:34 PM said:
???
You download them from the SDL site.

e.g. SDL_mixer:
http://www.libsdl.org/projects/SDL_mixer/
SDL_mixer-devel-1.2.7-VC6.zip

Thanks a million (again!!) for helping me! It's thanks to people like you that I am managing to produce games on the GP2X.

Sorry, it was me being a dumba$$!

I downloaded the source for the libs, not the headers and libs... Doh!! :blink:

Now it looks a LOT healthier, but I still can't link.

Project : Invaders
Compiler : GNU GCC Compiler (called directly)
Directory : C:\devkitGP2X\projects\Invaders\
--------------------------------------------------------------------------------
Switching to target: Windows
Compiling: shell.cpp
Linking executable: C:\devkitGP2X\projects\Invaders\Invaders.exe
C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 4 seconds)
0 errors, 0 warnings
 
Last edited by a moderator:
Blah posted on Jul 26 2006 at 08:51 PM said:
add "-dmain=SDL_main" to the parameters. Without the quotes of course.


EDIT: Doh, let me explain. The last problem I had was due to not including the lib file for Mingw32. I sorted that, and now I have an exe that starts and then quits. Presumably because I have no WinMain entry point. Looking at your posting, that's what sets it. Where do I include the line:-

dmain=SDL_main

?

Many thanks!!!!
 
Last edited by a moderator:
The exe flashes a black window up and then quits straight away. I get an empty stdout.txt and stderr.txt file? Any ideas what's going on here? Surely I would have something in the log, unless I still need that -dmain thing somewhere?
 
EDIT: Sorted! It seems to be related to a missing data file? Very odd. I copied my image libraries from the SD card and it works now.

Thanks very much for your help! I wouldn't have got it working without.

:D
 
Back
Top