GP32 compiling simple code on my GP32


Active Member
May 26, 2003
Ohhh clickable smileys(...sorry). I find myself getting more bemused by the second with the choices of devkits, I didn't expect it to be a piece of cake. All I wanted was a simple/free c/c++ compiler with an easy to use IDE. I started wth minigw where I have been stepping forwards and backwards ever since(damn makefiles, f**king spaces). The option I tried today was devkitadv ok I lose the IDE but I'm not afraid of notepad, and there is bound to be a few programmers editors out there. OK theres only a c example there, fine I think i'll stick to C. I thought get a little example running then I get "undefined reference to `cos'". Whats happened to math.h or stdio.h for that matter. I guess what I'm really asking is how different is writing C/C++ programs for the GP32 than say the PC, then I can ignore the differences and concentrate on the similarities i.e.

why can't I do this on a GP32

#include <iostream.h>
int main()
cout << "Hello, World\n";
return -1;

Instead I get this as an example

#ifndef __gpmain_h__
#define __gpmain_h__

void GpMain(void * arg);
int nflip, ExKey;

GPDRAWSURFACE gpDraw[2]; /* buffers */

#endif /*__gpmain_h__*/

test program

#include <stdlib.h>
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpstdio.h"
#include "gpfont.h"

void GpMain(void *arg)
int i;
GpClockSpeedChange(132000000, 0x24001, 2); /* speed = 133 Mhz */

nflip = 1;

/* Enable and clear LCD screen */
for(i = 0; i < 2 ; i++)
GpLcdSurfaceGet(&gpDraw, i);
GpRectFill(NULL, &gpDraw[nflip], 0, 0, gpDraw[nflip].buf_w, gpDraw[nflip].buf_h, 0xff);


srand(36547); /* seed random numbers */


GpTextOut(NULL, &gpDraw[nflip], 5, 5, "What did you expect? A freaking", 0);
GpTextOut(NULL, &gpDraw[nflip], 5, 21, "Hello World message?", 0);
/* flip the page */
nflip &= 0x01;
i've been doing a bit of gp32 coding in the last few weeks and there is quite a learning curve to it...

don't let anyone tell you it is easy! if you haven't done much programming before then you're probably going to struggle.

it IS different to programming c/c++ on a pc, for the simple reason you can't rely on a nice friendly IDE to do all the work for you, (well unless you pay £££££ for ADS), unfortunately you will have to learn about compiler switches and what makefiles actually do.

Rico's devkitadvance.rar is a good start, but there will still be plenty of issues to overcome and unfortunately help and decent documentation is pretty scarce.

this should help you with your math problem: (from the forum)

also Rico's example program is easy to follow, what's yer problem!?

the entry point for gamepark applications is 'GpMain' rather than 'main', that's the only difference.

this looks like a c++ win32 console or DOS app!
#include <iostream.h>
int main()
cout << "Hello, World\n";
return -1;
remember c++ files need to be named .cpp!

also i don't think the gamepark api has a standard output so this would not do anything anyway!
just use GpTextOut like in Rico's example! :p
Last edited by a moderator:
Well, writing an app for the GP32 is not that different than writing an app for the PC. The main difference, as feeblez told it, is the lack of a debugger. But I think I've seen somewhere it was possible to debug when developing under linux. The lack of debugger was my main concern when I begun to write my emulator. I extensively use GpTextOut() to display vars and so on... old school debugging :)

blah.. you can do cout << "foobar" << endl; etc.. you can do remote debug via USB (using GDB).. and you can trap all faults etc and check which function died & why & get the register dump. At least I can do it on my Mac OSX based development environment :rolleyes:
There is just no "cetnralized" attempt to do HAM like dev env. :(
Proper C++ support is always a pain (with GCC and for GP32).. at least if you want global objects to be constructed properly. Most crt0.o files around for GP32 don't do that. Current linkerscript seems to be ok though. If you want proper console output support you need to hack the libc for GP32, which basically means reimplementing some stuff in syscalls.c file. Everything is possible just not too easy yet with GP32 <_<