GP2X Help! Dev -c++


Well, I'm glad it worked :D

Anyway, it sounds like you should perhaps try a full clean re-install of Dev-C++ at home- maybe something fouled up earlier? Of course, it's probably fixable by a less drastic route, but if you don't know what's wrong, a re-install *could* fix it... also, I'm now trying to work out how I orginally fixed my problems of compiling SDL apps for Windows using Dev-C++ (the version of MinGW/GCC that comes with the latest version appears to not work properly with it for whatever reason). Last time I successfully made a new compiler profile that worked with SDL (I think I might have taken the binaries from my Codeblocks installation...) but like I said, I did a clean reinstall to test the wiki article as I wrote it, and in the process lost that :(

Anyway, good luck, because it would be a pain to only be able to compile projects at work ;P
 
Anyway, good luck, because it would be a pain to only be able to compile projects at work ;P
actually, that's no problem. My computer at work is a laptop which I can take home whenever I want to.

What's really a pain is the fact, that I have a complete game (SDL) ready and compiling but no GP2X to test it on... I think I'm gonna go nuts if it's not arriving today or tomorrow... :blink:

About compiling SDL-programs for windows using DevC++. I never had any problems with that. Just download DevC++, install the packages. (I think it's "Tools", "check for updates/packages..." or something like that.) Add the following parameters:
to Compiler: "-Dmain=SDL_main"
to Linker: "-lmingw32 -lSDLmain -lSDL"

that has always worked for me.

RomanH
 
hmmm... my GP2X arrived today (and I'm loving it!) but I simply can't get any self-compiled program to run... Not even the "Hello World" SDL program from the wiki works... All I get is a black screen...

I use the following build environment:
http://wiki.gp2x.org/wiki/Using_Devcpp

(SDL is installed, Firmware is 1.1.0)

has anyone been successful to run a program that has been compiled following the above mentioned method?

thanks!

RomanH
 
RomanH posted on Dec 23 2005 at 06:44 AM said:
hmmm... my GP2X arrived today (and I'm loving it!) but I simply can't get any self-compiled program to run... Not even the "Hello World" SDL program from the wiki works... All I get is a black screen...

I use the following build environment:
http://wiki.gp2x.org/wiki/Using_Devcpp

(SDL is installed, Firmware is 1.1.0)

has anyone been successful to run a program that has been compiled following the above mentioned method?

thanks!

RomanH

Sorry, just got around to reading this. Usually the black screen is a sign of missing or invalid library, compile with linker option '--static'.
From menu -'Tools' - 'Compiler Options' - 'Compiler' tab - put a checkmark in the line 'Add these commands to the linker command line' - type '--static' in box beneath it and click 'OK'

This works for me, and most of SOLs tutorials from wiki link (modified for joybuttons and 320x240, of course).
 
Last edited by a moderator:
I do not know if this may be of any help to you guys but here is something I have found.

http://www.bloodshed.net/dev/SetDevCPPArm.pdf

Maybe I will have a crack at it, I have once before trying to impliment the Visual Studio Express instructions for Dev-C++ but it all went horribly wrong...

But if we can get some sort of 'Package' for Dev-C++ working.... Now thats an Idea!
 
This is probably too little too late, but this is how I got Bloodshot to build Guyfawkes' SDL Test Demo.
Follow Guyfawkes' User manual instruction's (page 33) and confirm you can 'make' his demo from dos. I get 1 warning but the .gpe works on the GP2X.

In the following description you need to use the path to wherever you have put devkitGP2X, e.g H:\devkitpro\devkitGP2X\ or C:\devkitGP2X\. I shall use ..\devkitGP2X to represent this. Obviously you need to replace the ..\ with the path to your installation.

In Bloodshot, select Tools->Compiler options and add a new compiler by pressing the '+' button and giving it a name ie GP2X.
Tick the option to add commands to the linker and add the following in the window under it :
-static -lSDL -lSDL_image -ljpeg -lpng12 -lz -lpthread --start-group -lSDL_mixer -lvorbisidec -lmikmod -lSDL --end-group --start-group -lSDL_ttf -lfreetype -lm -lSDL --end-group

Select the directories tab and add ..\devkitGP2X\bin in the binaries tab (remember to replace ..\ with your path ie C:)
Then add ..\devkitGP2X\lib in the libraries tab
add ..\devkitGP2X\include and ..\devkitGP2X\include\SDL in the C includes tab
You are on your own when it comes to C++ (I don't use it) but you might try this in the C++ includes
..\devkitGP2X\lib\gcc\arm-linux\4.0.2\include
..\devkitGP2X\include\c++\4.0.2
..\devkitGP2X\include\c++\4.0.2\arm-linux
..\devkitGP2X\include\c++\4.0.2\backward
..\devkitGP2X\include
..\devkitGP2X\include\SDL
In the program tab set up the programs as described in the Wiki.

gcc.exe -> arm-linux-gcc.exe
g++.exe -> arm-linux-g++.exe
make.exe -> leave alone
gdb.exe -> leave alone
windres.exe -> leave alone
dllwrap.exe -> leave alone
gprof.exe -> arm-linux-gprof.exe

When you're done press OK.

Go to File->New->Project. In the dialogue set the name of your project. (I always build a C project and set it as default).
Select a console application and press Ok.
Save the project, probably best in a new folder.

In the project tab expand the tree and right click on main.c and remove it. No need to save it.
Now copy Guyfawkes' two files into your new project folder (using Windows explorer).
Go back to DevC and select project->add to project. Select the two files and press open.
Select Project->project options. Select the compiler tab and choose the new compiler you added earlier.
Select the build options tab and tick the overide output filename box. change the name so it has a .gpe extension.
select OK.

Go to Execute->rebuild all. This will produce a .gpe that works and, of course, you get the same warning that you get at the dos prompt.
If you find that the play a mod option doesn't work this is because Guyfawkes has left this as your first exercise on your road to GP leetness.

I have tried the other guides with no luck, but others have succeeded with them. No doubt this will not work for everyone but it may help someone.
This builds the project but note there is no call to strip the exe and no compiler parameters are used. That is your second exercise.
 
Last edited by a moderator:
Cool, but I think most of that duplicates the Wiki entry- of course, if you have something in there that isn't in the Wiki entry that's useful ( I think those linker options are a good example), then feed the Wiki and aid it's monstrous growth :)

I compiled mine without any errors or warnings IIRC, but I could be mistaken. Whether my .gpe binary actually works or not is a different matter since I still don't have a gp2x :p
 
I compiled mine without any errors or warnings IIRC, but I could be mistaken. Whether my .gpe binary actually works or not is a different matter since I still don't have a gp2x :p
I followed your wiki guide but I could not get it to work :( . Are you saying you successfully compiled Guyfawkes' test program without the warning?
The trouble with bl**dy computers when you are doing something like this is that your system may already have some sub system installed that you do not realise is necessary.
I think someone coming to this with a 'clean' machine needs to follow Guyfawkes' guide to have theoddbot's SDL libraries installed. Guyfawkes also says you need MinSys (what ever tf that is).
I don't claim to fully understand this and no doubt there is a 'proper' way to set this up but it worked for me. I don't know why your guide doesn't work for me as it does for you. I already had MinSys and Dev C installed ( been using it since I got my GP32), so I can only guess it is theoddbot's libraries. Even then it didn't work until I added the linker switches. Every one is neccessary or Guyfawkes' project won't build. Is this down to something I am doing wrong if you can build just using -lSDLmain and -lSDL ?
After having failed to get the wiki instructions for Visual C and Dev C to work, I thought this might help anyone else having problems.
If you think any of this would enhance your wiki guide please use it. I don't want to hack around with your contribution especially since this is a 'how I got it to work' rather than a 'I know what I am doing' sort of thing.
 
Last edited by a moderator:
I don't know what I'm doing either :p

But yes, I'm afraid mine compiles without warnings or errors :S very odd... You sure you have the latest versions of everything?

#include "SDL.h" may need to be changed to #include "SDL/SDL.h" but I doubt that's the source of your problems, because that would stop you from compiling the source altogether

Here is my compiled binary:

http://www.filelodge.com/files/hdd3/48109/Demo.gpe

Though obviously you download this entirely at your own risk and so forth (though I'd feel like shit if it did cause harm- not that I think it will obviously ;))
(sorry about the size, but of course I had to statically link to make sure of it working :))

Anyway, if it actually works on a GP2X that's definitely something.

If you think any of this would enhance your wiki guide please use it. I don't want to hack around with your contribution especially since this is a 'how I got it to work' rather than a 'I know what I am doing' sort of thing.

That's the whole point of a Wiki ;). That page was contributed originally by me, but if I understand rightly, by submitting it under the specific documentation license it's now PD, for anyone to use, edit etc. That's the main idea behind the system :)
 
I have tried your build but it just goes to a black screen and locks up. This is a build of Guyfawkes' sdltest program or are we talking at cross purposes ? The size of the file differs considerably from my build.
You say you didn't get a warning - is this because you are building a different project ? The warnings apply to the project not the environment and I get the same warning from the command line make file.
I am getting confused :blink: . This is the test code I used - Guyfawkes' SDL test in the archive.
If yours is a different project I will try and build it in my set up if you like. Just point me to the source.
 
That is the same link so we are talking about the same source :) . If I use Guyfawkes' make file (from the dos console) I get the same warning I get in Dev C :

[..\devkitGP2X\lib\libmikmod.a(mdriver.o) [Warning] Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

but the program runs fine on the hardware. The file you linked to, demo.gpe is 123kb while when I compile it it comes to 2,597kb. Demo.gpe locks up with a black screen on the hardware.
This is a mystery. Could you post a link to the Makefile.win Dev C generated for your build of Demo.gpe please. I am going to try and understand this if it kills me. I don't understand how you compiled it with just the -lSDLmain -lSDL switches. The make file might gives us a clue to what I am missing. Cheers.
 
I downloaded it again and now have the right file size 839Kb. Unfortunately I still get the same result - black screen and lock up. :(

As there is no explanation in the wiki to stripping within Dev C I gave the unstripped size of it. Stripped it is 2330Kb.
 
digitaljez, I used your instructions along with the gp2x user guide instructions and I got it to compile with one warning and work on my gp2x! Thanks, now I just have to learn c and SDL (i started learning c++ a long time ago but I gave up and now i've forgotten it. All I can program in right now is visualbasic).

Here is the warning I get:
Code:
[warning] Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Do you know what this means?


Thanks again,
-ben

EDIT: Ok, I tried to compile a hello world program from a tutorial on the wiki and I got the following errors:
Code:
unrecognized command line option "-fstart-group"
unrecognized command line option "-fend-group"
It says this twice, with "cc1plus.exe: error: " before each one. I don't know c/c++ or SDL and don't know what this means......
HERE is a link to the tutorial.
 
Get rid of -fstart-group and -fend-group from command line, it should compile then.

I compile mine in CodeBlocks and end up with 2.27 mb. :(

Used the gpe compressor and I get it down to 923k but takes ages to start up.

Ferentix's gpe locks up as well on mine.
 
digitaljez, I used your instructions along with the gp2x user guide instructions and I got it to compile with one warning and work on my gp2x! Thanks, now I just have to learn c and SDL (i started learning c++ a long time ago but I gave up and now i've forgotten it. All I can program in right now is visualbasic).

Here is the warning I get:
Code:
[warning] Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Do you know what this means?


Thanks again,
-ben

EDIT: Ok, I tried to compile a hello world program from a tutorial on the wiki and I got the following errors:
Code:
unrecognized command line option "-fstart-group"
unrecognized command line option "-fend-group"
It says this twice, with "cc1plus.exe: error: " before each one. I don't know c/c++ or SDL and don't know what this means......
HERE is a link to the tutorial.
The warning is being generated by a reference in the libmikmod.a library. I get it too. I have gathered from gfoot that it could be solved by recompiling the lib. It is saying the code for the function 'getpwnam' is in the libraries on the device and is not statically linked into the program. I understand from gfoot that it is some sort of user mode password call but we are running in supervisor mode so it should never be called. If it did get called this would be a bad thing as the glibc is not available at runtime. (someone correct me if I am talking b*ll*cks).
As yaustar says get rid of the --startgroup/--endgroup from the linker command line. I have changed the linker parameters in my setup to :
-static -lSDL_mixer -lSDL_ttf -lSDL_image -lmikmod -lvorbisidec -lfreetype -ljpeg -lpng12 -lz -lm -lSDL -lpthread

It would probably make more sense to put the linker commands in the project rather than the compiler. You may not always want the SDL libs.

Thanks for letting us know it worked for you too. It works for me using the arm-linux-c++.exe as well as the c compiler. All we need now is for someone to explain the optimal compiler command line parameters and I guess we could update ferentix's Dev C++ wiki entry.
 
Last edited by a moderator:
Well, I tried it all again from scratch last night and the hello pixel program compiled fine with only that warning...... and I don't think I changed anything.....

Anyways, thanks for the help, I will try that when I get home (i'm at school right now, and I'm actually in a programming class right now. Of course, we don't actually learn anything, most students are playing age of empires 2 right now, as are the teacher and another member of the tech department at my schoool).
 
Having joined this thread quite late and never read the beginning until now, I have just realised how off topic it as gone. I would like to apologise to mattyrb for my part in this hijack and wondered if you have resolved the original issue ?

@yaustar - exactly. Which do we really need and what do they do ? I am currently not using any. I know RTF would be a valid response to this, but why not have a clear explanation given by forum members to help other members ? I would much rather learn from others than a manual. The results could be added to the wiki so that a search for compiler switches or compiler commands returned something useful for those who like manuals.

@deadlychicken22 - sorry to hear about your programming class, that sucks. Does the pixel program use mods ? You may not need the lib that is causing the warning (or any SDL libs at all for that matter). That is why it would be better to set the linker switches in the project rather than the compiler. This is useful feedback for refining the information before putting it into the wiki.
 
Back
Top