Getting Codeblocks To Work...


DavidBeoulve

GP2X by EvilDragon OC's to 280-300MHz
Joined
May 10, 2006
Messages
427
Age
48
Location
USA
Website
www.gamersgonebad.com
I've got CodeBlocks up and running and configured - near as I can tell. PokeParadox RARed up his Application Data CodeBlocks folder as well as his actual CodeBlocks install directory and his devkitGP2X install directory and gave me those -- already configured.

So I downloaded the test:
http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,46,1047

And I get this message when attempting to compile:
CODE

sdltest.cpp:(.text+0xc):: undefined reference to `SDL_FreeSurface'
sdltest.cpp:(.text+0x18):: undefined reference to `SDL_FreeSurface'
sdltest.cpp:(.text+0x24):: undefined reference to `SDL_FreeSurface'
sdltest.cpp:(.text+0x30):: undefined reference to `Mix_FreeChunk'
sdltest.cpp:(.text+0x3c):: undefined reference to `Mix_FreeMusic'
sdltest.cpp:(.text+0x40):: undefined reference to `Mix_CloseAudio'
sdltest.cpp:(.text+0x4c):: undefined reference to `TTF_CloseFont'
sdltest.cpp:(.text+0x50):: undefined reference to `TTF_Quit'
sdltest.cpp:(.text+0x9c):: undefined reference to `TTF_OpenFont'
sdltest.cpp:(.text+0xf8):: undefined reference to `TTF_RenderText_Blended'
sdltest.cpp:(.text+0x120):: undefined reference to `SDL_UpperBlit'
sdltest.cpp:(.text+0x128):: undefined reference to `SDL_FreeSurface'
sdltest.cpp:(.text+0x1a0):: undefined reference to `TTF_RenderText_Blended'
sdltest.cpp:(.text+0x1cc):: undefined reference to `SDL_UpperBlit'
sdltest.cpp:(.text+0x1d4):: undefined reference to `SDL_FreeSurface'
sdltest.cpp:(.text+0x240):: undefined reference to `SDL_UpperBlit'
sdltest.cpp:(.text+0x260):: undefined reference to `SDL_PollEvent'
sdltest.cpp:(.text+0x2a4):: undefined reference to `SDL_PollEvent'
sdltest.cpp:(.text+0x2e8):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x2fc):: undefined reference to `SDL_FillRect'
sdltest.cpp:(.text+0x3a8):: undefined reference to `SDL_Flip'
sdltest.cpp:(.text+0x3fc):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x40c):: undefined reference to `SDL_FillRect'
sdltest.cpp:(.text+0x414):: undefined reference to `IMG_Load'
sdltest.cpp:(.text+0x424):: undefined reference to `SDL_ConvertSurface'
sdltest.cpp:(.text+0x49c):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x4ac):: undefined reference to `SDL_SetColorKey'
sdltest.cpp:(.text+0x4e4):: undefined reference to `IMG_Load'
sdltest.cpp:(.text+0x4f4):: undefined reference to `SDL_ConvertSurface'
sdltest.cpp:(.text+0x564):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x574):: undefined reference to `SDL_SetColorKey'
sdltest.cpp:(.text+0x5a8):: undefined reference to `IMG_Load'
sdltest.cpp:(.text+0x5b8):: undefined reference to `SDL_ConvertSurface'
sdltest.cpp:(.text+0x618):: undefined reference to `IMG_Load'
sdltest.cpp:(.text+0x62c):: undefined reference to `SDL_ConvertSurface'
sdltest.cpp:(.text+0x66c):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x67c):: undefined reference to `SDL_SetColorKey'
sdltest.cpp:(.text+0x6a8):: undefined reference to `rotozoomSurfaceXY'
sdltest.cpp:(.text+0x6c8):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x6d8):: undefined reference to `SDL_SetColorKey'
sdltest.cpp:(.text+0x730):: undefined reference to `SDL_Flip'
sdltest.cpp:(.text+0x74c):: undefined reference to `SDL_FreeSurface'
sdltest.cpp:(.text+0x7d8):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0x7e8):: undefined reference to `SDL_FillRect'
sdltest.cpp:(.text+0x850):: undefined reference to `SDL_Flip'
sdltest.cpp:(.text+0x858):: undefined reference to `SDL_PollEvent'
sdltest.cpp:(.text+0x928):: undefined reference to `SDL_PollEvent'
sdltest.cpp:(.text+0xc64):: undefined reference to `SDL_MapRGB'
sdltest.cpp:(.text+0xc78):: undefined reference to `SDL_FillRect'
sdltest.cpp:(.text+0xca0):: undefined reference to `SDL_Flip'
:: More errors follow but not being shown.
:: Edit the max errors limit in compiler options...
:: === Build finished: 50 errors, 0 warnings ===


Reading from this page:
http://wiki.gp2x.org/wiki/Using_CodeBlocks
 
It seems like you did not include <SDL.h>, <SDL_ttf.h>, etc. Perhaps Codeblocks is set to look for them in the wrong folder, double check that.
 
He probably has an environment variable pointing to where SDL is located on his computer and you don't. Check the project details on additional include directories and then if it's using an environment variable such as %SDL_DIR%. If it does, you'll have to set the environment variable SDL_DIR to point to where your sdl src files are located.
 
I've never used codeblocks, but that there is a good old fashioned linking error. Did you check to see if the project is linking in the SDL libs?
 
Yes this looks like a linker error.

David:
Under the Project menu you will find Build options.
There should be a tab called Linker in the window that just opened, go there.
now there should be a list with all the libaries you are linking with, if SDL and SDLmain are not there, your project will not link.
Using add button; if you want to compile for the 2x, navigate to the devkit2x's lib directory and add the libaries you need (looks like you need libSDL, libSDLmain, libSDL_mixer, libSDL_image and libSDL_ttf).
If you want to compile for the pc, go to your code::blocks lib directory instead.
 
Thank you Damascus (I'm aware of what a damascus blade is :) ) and Ninjak (not sure where to look for that one) and Alex and DockThePod.
I added this to "Settings," "Compiler and Debugger," "Linker Settings," in the right window "Other Linker Options"

CODE
C:\devkitGP2X\include
C:\devkitGP2X\include\SDL
C:\devkitGP2X\lib
C:\devkitGP2X\lib\gcc\gp2x\4.0.2

After compiling I get this result:
CODE
-------------- Build: Release in NewTest ---------------
Linking console executable: bin\Release\NewTest.exe
c:\devkitgp2x\bin\..\lib\gcc\arm-linux\4.0.2\..\..\..\..\arm-linux\bin\ld.exe: C:\devkitGP2X\include: No such file: Permission denied
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings


Nothing is in the left field. I had put some stuff in there but taking it out didn't change the above result, so either it was wrong or... the right handles it?

Still, I then put in the left (adding each)
  • libSDL.a
  • libSDL_mixer.a
  • libSDL_image.a
  • libSDLmain.a
  • libSDL_gfx.a
  • libSDL_ttf.a
No change in the compile. Looking in the project directory (bin & obj) I find no final GPE or EXE, but you'd think with 0 warnings or errors, it'd compile.

Here's my Compiler Toolchain settings...
t_compilertoom_4155a58.gif
 
Why not start from scratch with the Using Codeblocks Article open? Now that you got a feel for this, you'll set it up quickly, and cleanly. Its kind of dodgy to copy settings folders and the like from others, who knows where a little synchronization issue popped up, could take more time than it's worth to track down.

Good luck :)
 
Ah, you have a different version of CB, so my instructions where a bit off.
The "other linker options" list should be empty, it's a place to specify commands to the linker and you are trying to feed it the search paths, which confuses the linker.

This is also why you dont get any Compiler warnings or errors, there is nothing (probably) wrong with your code, but the linker simply fails to execute, since it tries to open the path you entered as a file.

It should be enugh to just add those libaries to the left window, and have the right window empty.

However, you are changeing the global options, this means that when you start a new project, these settings will remain.
I think it would be better if you undid the things you did under the settings menu and changed the project specific options under Project->BuildOptions .
The linker settings tab that i mentioned before have apparently been moved to a dropdown list (the second from the top).
 
Alex. said:
Why not start from scratch with the Using Codeblocks Article open? Now that you got a feel for this, you'll set it up quickly, and cleanly. Its kind of dodgy to copy settings folders and the like from others, who knows where a little synchronization issue popped up, could take more time than it's worth to track down.

Good luck :)


*chuckles* ... because I've already done that. I deleted everything (including the data in my Applications Data area) and started over and came up with the same result. The Wiki was made for an earlier version of CodeBlocks. I'd update it if I knew what to do to set CodeBlocks up - clearly I don't ;)

Dimacus said:
Ah, you have a different version of CB, so my instructions where a bit off.
The "other linker options" list should be empty, it's a place to specify commands to the linker and you are trying to feed it the search paths, which confuses the linker.

This is also why you dont get any Compiler warnings or errors, there is nothing (probably) wrong with your code, but the linker simply fails to execute, since it tries to open the path you entered as a file.

It should be enugh to just add those libaries to the left window, and have the right window empty.

However, you are changeing the global options, this means that when you start a new project, these settings will remain.
I think it would be better if you undid the things you did under the settings menu and changed the project specific options under Project->BuildOptions .
The linker settings tab that i mentioned before have apparently been moved to a dropdown list (the second from the top).
Ah ho ha! Okay, well this explains why PokeParadox's setup had nothing listed in here.

What goes in the Link Settings tab? The links to the .a files?

What's the disadvantage of having every project link to these things, other than size of resulting GPE?

I misread your moniker, Dimacus - I was thinking of the Damascus Blade.
 
Last edited by a moderator:
Okay I took out the reference to the library files in the linker options - that helps... literally. But I got a new result:

CODE
:: === NewTest, Release ===
SDL_sysmutex.c:(.text+0x108):: undefined reference to `pthread_mutexattr_init'
SDL_sysmutex.c:(.text+0x114):: undefined reference to `pthread_mutexattr_setkind_np'
SDL_systhread.c:(.text+0x4):: undefined reference to `pthread_cancel'
SDL_systhread.c:(.text+0x10):: undefined reference to `pthread_join'
SDL_systhread.c:(.text+0x60):: undefined reference to `pthread_sigmask'
SDL_systhread.c:(.text+0xc8):: undefined reference to `pthread_create'
SDL_syssem.c:(.text+0x24):: undefined reference to `sem_post'
SDL_syssem.c:(.text+0x7c):: undefined reference to `sem_getvalue'
SDL_syssem.c:(.text+0xbc):: undefined reference to `sem_wait'
SDL_syssem.c:(.text+0x110):: undefined reference to `sem_trywait'
SDL_syssem.c:(.text+0x1cc):: undefined reference to `sem_destroy'
SDL_syssem.c:(.text+0x20c):: undefined reference to `sem_init'
mixer.c:(.text+0xcb8):: undefined reference to `SDL_ReadLE32'
mixer.c:(.text+0xd60):: undefined reference to `SDL_LoadWAV_RW'
mixer.c:(.text+0xdf0):: undefined reference to `SDL_FreeWAV'
mixer.c:(.text+0xe84):: undefined reference to `SDL_FreeWAV'
mixer.c:(.text+0xec0):: undefined reference to `SDL_FreeWAV'
mixer.c:(.text+0x1d54):: undefined reference to `SDL_MixAudio'
mixer.c:(.text+0x1ec4):: undefined reference to `SDL_MixAudio'
music.c:(.text+0x3ec):: undefined reference to `SMPEG_setvolume'
music.c:(.text+0x4f8):: undefined reference to `SMPEG_status'
music.c:(.text+0x600):: undefined reference to `SMPEG_skip'
music.c:(.text+0x61c):: undefined reference to `SMPEG_rewind'
music.c:(.text+0x628):: undefined reference to `SMPEG_play'
music.c:(.text+0x71c):: undefined reference to `SMPEG_stop'
music.c:(.text+0x7ec):: undefined reference to `SMPEG_setvolume'
music.c:(.text+0xd2c):: undefined reference to `SMPEG_new'
music.c:(.text+0xd80):: undefined reference to `SMPEG_actualSpec'
music.c:(.text+0xe54):: undefined reference to `SMPEG_stop'
music.c:(.text+0xf80):: undefined reference to `SMPEG_setvolume'
music.c:(.text+0x104c):: undefined reference to `SMPEG_enableaudio'
music.c:(.text+0x1058):: undefined reference to `SMPEG_enablevideo'
music.c:(.text+0x1064):: undefined reference to `SMPEG_play'
music.c:(.text+0x10d8):: undefined reference to `SMPEG_stop'
music.c:(.text+0x1140):: undefined reference to `SMPEG_setvolume'
music.c:(.text+0x119c):: undefined reference to `SMPEG_skip'
music.c:(.text+0x11b8):: undefined reference to `SMPEG_rewind'
music.c:(.text+0x11c4):: undefined reference to `SMPEG_play'
music.c:(.text+0x13d4):: undefined reference to `SMPEG_delete'
music.c:(.text+0x1460):: undefined reference to `SMPEG_stop'
music.c:(.text+0x1564):: undefined reference to `SMPEG_status'
music.c:(.text+0x16cc):: undefined reference to `SMPEG_stop'
music.c:(.text+0x171c):: undefined reference to `SMPEG_playAudio'
music.c:(.text+0x1778):: undefined reference to `SMPEG_setvolume'
music.c:(.text+0x1844):: undefined reference to `SMPEG_stop'
wavestream.c:(.text+0x1c4):: undefined reference to `SDL_MixAudio'
wavestream.c:(.text+0x238):: undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0x244):: undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0x348):: undefined reference to `SDL_ReadLE32'
wavestream.c:(.text+0x354):: undefined reference to `SDL_ReadLE32'
:: More errors follow but not being shown.
:: Edit the max errors limit in compiler options...
:: === Build finished: 50 errors, 0 warnings ===



This is for the same SDL test.
 
Just wipe everything off, download the standard non-nightly build of CodeBlcoks 1.0 RC 2, and follow the wiki step by step.
 
Alex. said:
Just wipe everything off, download the standard non-nightly build of CodeBlcoks 1.0 RC 2, and follow the wiki step by step.
Err, other than using the non-nightly build, I have already done that.

t_ScreenShot0m_526030d.png
Okay there are my Linker Settings.

Alex, what version of CodeBlocks should I use to make what the Wiki says actually work? Because something we're glossing over here is that there are instructions there that don't match up to what CodeBlocks says or lets me do. I've done it twice and ended up with bad results so... what version are you using? Or can you update the Wiki pretty please?
 
Last edited by a moderator:
Thank you Alex!

I got PokeParadox's project to compile!

t_ScreenShot0m_700c858.png
That's my linker settings

CODE
-------------- Build: Release in SDLGP2XTest ---------------
Linking console executable: bin\Release\SDLGP2XTest.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

And there's the result!

SDL_test still doesn't work...
 
Wait, are you trying to compile a file that you can run on your computer, or one to run on the 2x?
Also, is PokeParadox's project the same as SDL_test, or are they different and you have gotten PokeParadox's project to execute, but the SDL_test still wont compile?
 
Dimacus said:
Wait, are you trying to compile a file that you can run on your computer, or one to run on the 2x?
Also, is PokeParadox's project the same as SDL_test, or are they different and you have gotten PokeParadox's project to execute, but the SDL_test still wont compile?
Thank you for your time, Dimacus.

Right now, I am trying to successfully compile. Eventually, the goal is to compile for the GP2X and perhaps the PC for ease of testing.

PokeParadox's project is something he's working on. He stripped out most of the code and left the engine so I can get started more easily. I didn't try to run it, as I assumed it was a GP2X .GPE file... I just checked, both are generated, but the EXE says in the DOS prompt "Program too big to fit into memory." which I believe is an erroneous error message unless it's addressing memory that's no longer used in PCs.

That is correct, SDL_test still won't compile.
 
Last edited by a moderator:
Yeah you should try to run the "EXE" on a PC, since it is in fact a GPE file. I've given up trying to make the setting stay that makes it a GPE for you. Now I just copy it to the 2X and rename it manually.

Sorry to hear you are still not having so much luck :S It's quite worrying to see how fickle setting up a dev environment can be...
 
PokeParadox if you are awake get on Gmail IM.

(mutters something about 'this is something I complained about on IRC before my stick broke and only one guy listened')

Actually back then, believe it or not, I had a development environment up and running, even compiled and ran hello world and whatnot. Unfortunately I wiped my wife's PC between now and then and didn't back it up because - the GP2X was busted - and I didn't expect this to happen on the off-chance I had a 2nd chance.

What I complained about in IRC is the difficulty in getting the specific bits of knowledge together that any other progarmming environment is easy and there are loads of folks with knowhow and very few tutorials - and no "this is a parallax engine" kinda stuff going on. Basically, to become a GP2X dev you hang out in IRC, which is fine for some, but I was trying to convey "How many people are going to work as hard to get here to realize this is what you need to do?"

So a compiler is not going to stop me - least of all not without your collective help!
 
Back
Top