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]



  1. Thanks for the tutorial. Just to say that I found a problem when compiling the sdk on Ubuntu Edgy, some version.c parsing string error. I had the same problem with the ATI driver installer so I will explain my working trick. In fact the problem comes from sh, the scripting language used with the scripts. So either change in all scripts the first line #! /bin/sh with #! bin/bash or TEMPORARLY backup /bin/sh, then copy /bin/bash -> /bin/sh . Then use the script (should now work). Then put back /bin/sh.back -> /bin/sh.

    Here you go !


    Comment by Alex — 2006/11/18 @ 20:44 | Reply

  2. I think that Libraries and sdl-config Scripts should be already fixed in GPH’s downloads.

    Is GPH warned yet? Can you do it for the all community?

    Thanks in advance.

    Comment by andandare — 2006/12/11 @ 16:28 | Reply

  3. Very nice howto, thanks a lot!

    Comment by andandare — 2006/12/11 @ 16:54 | Reply

  4. Hi Andandare. I think I’ll contact GPH about fixing the paths in their SDK installer. But I must say that I’ve switched to using ooPo’s toolchain meanwhile. Seems to be much better. Cheers!

    Comment by FrankZabbath — 2006/12/19 @ 20:36 | Reply

  5. Hi

    I was directed here via the GP2X development wiki. The wiki said follow your guide so I did, but I was confused when extracting gp2x-library.tar.gz into ${PREFIX}/ because the gp2xsdk readme.txt states ${PREFIX}/arm-gp2x-linux. When I ran the first script to fix the libraries/sdl-config scripts I was presented with an error from sed stating unknown ‘s’ which I suppose is the ‘s’ at the start of the string.

    I never got any further with this guide as I decided to do what the gp2xsdk readme.txt said as some time has passed since this guide was written. This time I extracted gp2x-library.tar.gz into ${PREFIX}/arm-gp2x-linux which when looking at the contents of the tarball seemed pretty logical. I couldn’t find anything wrong with the library symlinks but there are definitely some hardcoded paths inside some of the scripts such as arm-linux-sdl-config, sdl-config and freetype-config (I haven’t yet searched for any more). In the case of arm-linux-sdl-config, the path can be overridden by passing –exec-prefix=${PREFIX} and I have tested it because I’ve already built some test applications. freetype-config also accepts this command line argument but I haven’t tested it. Therefore if you want to install the gp2xsdk as instructed in the included readme.txt and compile an SDL application then you simply need this Makefile (obviously changing SOURCES, OBJECTS and TARGET to match your project) :-


    # Settings for GP2X.

    CFLAGS=-O2 -Wall -pedantic -I$(PREFIX)/arm-gp2x-linux/include `$(PREFIX)/arm-gp2x-linux/bin/arm-linux-sdl-config –exec-prefix=$(PREFIX) –cflags`
    LIBS=`$(PREFIX)/arm-gp2x-linux/bin/arm-linux-sdl-config –exec-prefix=$(PREFIX) –libs`

    $(CC) $(CFLAGS) -c $(SOURCES)

    .PHONY: clean

    rm $(OBJECTS)
    rm $(TARGET)

    I saved it as Makefile.gp2x so that executing “make -f Makefile.gp2x” compiles it.

    I hope this helps new GP2X developers setting up the GPH gp2xsdk.


    Comment by Thunor — 2007/06/04 @ 23:34 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: