Bembel-B Blog


Setting Up a Linux Cross Compiling Environment for GP2X with Gamepark Holdings’ SDK gp2xsdk

I recently bought myself the Gamepark Holdings GP2X a Linux driven handheld entertainment console. Arcade and gaming console emulators etc. work quite nicely on this machine. Also the potential is large, as it’s an all open architecture.


So I wanted to try a little development for this fine unit esp. with some C brand and SDL. As the GP2X has two ARM CPUs and compiling directly on the unit would be darn slow one would have to setup a cross compiling environment. You could do that on Windows or Linux or whatever, but I chose Linux of course. I use Fedora Core 5 on an x86 architecture.

Nota Bene

There are several ways to set up such a cross compiling environment and sadly the information on the nonetheless very useful GP2X Wiki is very sparse and outdated. As I’m totally unexperienced in cross compiling and only got basic (i.e. little not the “programming language” BASIC ;) knowledge of software development under Linux, I wanted to take a simple and mostly “official” approach with the SDK provided by Gamepark Holdings (GPH) released 06-07-2006 to get the compiler toolchain and the most important libraries.

Also there’s the problem that alternatives similar to my approach (section A and B in the aforementioned Wiki page), like ooPo’s build environment and the installer script by gamkiller, are not found on their authors websites anymore, are outdated, contain strange looking programm versions and the GPH SDK release is newer. So these alternatives didn’t seem very good to me. However these environments will be packed with more libraries than the GPH SDK.

Remind: This procedure works for me. There are very likely some errors or things not done the best way. Check back for changes!

One final foreword: To be able to run the programms built for the GP2X on your PC, you would have to setup some VM like Scratchbox. Scratchbox also contains a cross compiling environment. But this seemed to complicated for a first try, but you might want take a look at that!

Prepare the SDK Installation

I assume you got the basic development tools (gcc, g++ etc.) installed on your system.

Download the GPH SDK from the GPH website. Currently the URL is
Extract it somewhere on your system.

Now edit the extracted and change the installation destination defined by export PREFIX="/some/where" to your liking. Beware that this destination is hard coded; you cannot move the SDK afterwards without making it disfunctional. This destination must be writable for the user executing the build script in the next step.
For the path set there I will use ${PREFIX} as a placeholder from now on. So be sure to exchange ${PREFIX} with e.g. /some/where.

Build the SDK

Now cd to the destination of the extracted gp2xsdk_linux.tar.gz and run the build script

Additional files will be downloaded and then compilation starts. This all takes about 45 minutes on my Athlon XP 2500+ and needs about 800 MB disk space IIRC.

Everything has to go through without errors. If the build script aborts with an error, you’re maybe missing some build tools or other dependencies. Or ran out of disk space. ;) Investigate in this case!

All files will be put to the destination defined via PREFIX in

Install the Libraries

Extract gp2x-library.tar.gz contained in gp2xsdk_linux.tar.gz into ${PREFIX}/. That’s it for now.

Clean Up the SDK Build and Installer

The files downloaded by the build script can be deleted. They’re all in ${PREFIX}/files.

The build directory of the SDK can probably be deleted, as they were installed into ${PREFIX}/. They’re all in ${PREFIX}/build.

The extracted sources to build the SDK can probably also be deleted I guess. They’re all in ${PREFIX}/src. Not sure about this though. Maybe better do a backup of this directory before removing.

The files exctracted from gp2xsdk_linux.tar.gz can obviously be deleted.

Fix the Libraries and sdl-config Scripts

Some of the libraries’ files (*.la) from gp2x-library.tar.gz contain wrong path names. These have to be fixed. I adapted this from the install script by gamkiller. You must cd into ${PREFIX} and then run the following commands, with the sed substitution modified to your PREFIX path. Mine in this command is /home/scheff/wrk/gp2x/gph_sdk/gp2xsdk/Tools, a bit looong, eh. Note that the paths slashes have to be escaped (/ becomes \/).

for a in lib/*.la; do
cp -p "$a" "$a.orig"
sed -e 's/\/usr\/local\/gp2x-library\/image/\/home\/scheff\/wrk\/gp2x\/gph_sdk\/gp2xsdk\/Tools/g' "$a.orig" > "$a"

This will make a backup of all *.la files in ${PREFIX}/lib and change the default paths to yours.

The sdl-config also contains wrong paths. Strangely they differ from the default path found in the libraries above. Also the sdl-config is extisting twice (${PREFIX}/bin/sdl-config and ${PREFIX}/bin/arm-linux-sdl-config) with different contents. This shouldn’t be the case I think. So we will fix one sdl-config and create a symlink for the duplicate.

You could correct the path in the file easily with an editor. Its the prefix variable at the beginning of the file.

But as I wrote it and it looks soo ubercool, here’s a sed command. Again be sure to have cd’ed to your PREFIX and set the right path in the sed substitution statement:

cp -p "$a" "$a.orig"
sed -e 's/\/hd\/nk\/SDL\/image\//\/home\/scheff\/wrk\/gp2x\/gph_sdk\/gp2xsdk\/Tools/g' "$a.orig" > "$a"

Now for the symlinking for the dupe sdl-config:

pushd bin
rm sdl-config
ln -s arm-linux-sdl-config sdl-config

Use the SDK

Finally you are now able to use the cross compiling environment! Congratulations and celebrations! :]

For the ease of use add the ${PREFIX}/bin to your PATH environment variable like this:

export PATH=${PREFIX}/bin:$PATH

A simple Hello World C++ application should now compile and run for your GP2X ARM CPU compiling with arm-gp2x-linux-g++.

Haven’t yet tried some C++ Hello World to stdout, but guess it’ll run fine in the console (e.g. sterm). My first attempt was the SDL Hello Pixel example, which I will cover in my next posting in this Blog. So much beforehand: it works! :)

Thanks and Credits

A thousand thanks and credits go to:
all the Open Source developers making this possible
GPH for the SDK for providing the information
gamkiller for the installer script
some unknown people’s postings found via search engines
my mom and dad – and you for your interest in all this! :p

“Good night and good luck!”


[070429 Add photo]


Create a free website or blog at