Walk-through: Setting up GP2XSDK in Linux

This walkthrough was tested in a clean install of Ubuntu Fiesty, though there should be no reason for it not to work on most flavours of Linux. The intention is to run you through a no-frills install of the official SDK, configuring the environment to use it, and finally test compiling some demo code. There is plenty of scope for improvement, such as moving the SDK directory out of the filesystem root, but this will get you up and running quickly so you can start experimenting.

Final point: I performed my installation in a virtual machine. This is completely personal preference, but I recommend it as you will be keeping the GP2X development environment separate from your main system, if things go wrong and you want to start afresh, you can just delete the image and create a new one. There are no uninstall scripts for the SDK and it copies files to the root of your filesystem, which some can find messy. Again, this is a preference thing.

Onto the walk-through!

1. Install dependancies for SDK

~$ sudo aptitude install subversion build-essential

2. Ensure /bin/sh symlink points to /bin/bash

The SDK install scripts expect /bin/sh to be pointing to the /bin/bash shell, but Debian-based distro’s often point to /bin/dash instead – check this with:

~$ ls -l /bin/sh

If the output looks like “/bin/sh -> /bin/dash” you will need to do the following:

~$ sudo mv /bin/sh /bin/sh-original

~$ sudo ln -s /bin/bash /bin/sh

3. Get the SDK

Download at: http://dev.gp2x.com/sdk/gp2xsdk_linux.tar.gz and extract the archive.

(Contact me if this link is bad)

4. Run the install script

~$ cd gp2xsdk_linux

~$ sudo ./buildgp2xtools.sh

5. Go make a cup of tea, this will take a while…

6. Once complete, revert /bin/sh to original (skip this step if you didn’t need to do step (2))

~$ sudo rm /bin/sh

~$ sudo mv /bin/sh-original /bin/sh

7. Copy the SDL libraries into /gp2xsdk

~$ sudo tar –directory=/gp2xsdk/ -zxf gp2x-library.tar.gz

8. Create a user account to develop for GP2X on (you will need to “su gp2xdev” before you start coding for GP2X)

This ensures your normal account still allows you to use the normal GNU toolchain for your system

~$ sudo adduser gp2xdev

I advise you continue to use a secure password for this account, this ensures that any privileges you give it do not compromise the system. Next, we will switch to the GP2X development account, and configure the PATH environment variable to use the SDK toolchain:

~$ su gp2xdev

~$ echo “export PATH=/gp2xsdk/Tools/arm-gp2x-linux/bin:\$PATH” >> ~/.bashrc

9. Exit the account and switch to it again, this will apply the new PATH

~$ exit

~$ su gp2xdev

10. You should now be using the SDK toolchain

Test by typing “g++ –version”, The first line should read “g++ (GCC) 3.4.6”.

11. Download the demo code from:


12. You will also need an 8 bit bitmap image

Create an bitmap image that is 320×240 pixels in size (this will fill the screen) with a 256 colour index.

Save it under the name “image.bmp”.

13. To compile the demo, navigate into the directory containing demo.c and use this command:

~$ gcc demo.c -I/gp2xsdk/include/SDL -L/gp2xsdk/lib -lSDL -o demo.gpe

14. Copy the files onto an SD card

Copy the bitmap image onto the ROOT of your SD card (ensure it is named “image.bmp”, as this is what is defined in the example code)

Copy the compiled “demo.gpe” program anywhere on your SD card

15. Fire up your GP2X, navigate the menu to Games->SD Memory Card, then find and run your “demo” program.

If all goes well you should see the image appear on the screen. Press any button to exit back to the menu.

N.B. If instead the program hangs, you have probably not placed the bitmap image in the right place or named it correctly.

Good luck!


2 Responses to Walk-through: Setting up GP2XSDK in Linux

  1. paris says:

    Hi Sean,

    After having to do a new OS install, I needed to set up the gp2x dev environment again and needed a refresher on the steps.

    Luckily I found your page again and I think this must be the best tutorial out there!

    I think I might make a text file out of it and store it with the source code just in case I ever need it again 😉


  2. […] If you dont have the knowledge of installing the scripts you want on your website, we offer fast installation of CGI scripts. Read More… […]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: