Gph Sdk Linker Error


Girvo

Still Fresh
Joined
Nov 9, 2006
Messages
11
Hi there.

I went and got the SDK from the GPH website, and extracted it no sweat. I fired it up, created a standard template project, and proceeded to compile it. It worked fine for windows, it ran and everything.

But, as soon as I changed the compiler options from win to gp2x, it stopped linking.

[Linker error] undefined reference to `WinMain@16'

Was the error I got. Any ideas?

-Girvo
 
Hi there.

I went and got the SDK from the GPH website, and extracted it no sweat. I fired it up, created a standard template project, and proceeded to compile it. It worked fine for windows, it ran and everything.

But, as soon as I changed the compiler options from win to gp2x, it stopped linking.

[Linker error] undefined reference to `WinMain@16'

Was the error I got. Any ideas?

-Girvo

Sounds like you are including the window.h header when you compile for the gp2x just use ifdef WIN32 include all windows stuff endif etc... this should fix your problem.
 
Last edited by a moderator:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <SDL.h>

/* GP2X button mapping */
enum MAP_KEY
{
	VK_UP		 , // 0
	VK_UP_LEFT	, // 1
	VK_LEFT	   , // 2
	VK_DOWN_LEFT  , // 3
	VK_DOWN	   , // 4
	VK_DOWN_RIGHT , // 5
	VK_RIGHT	  , // 6
	VK_UP_RIGHT   , // 7
	VK_START	  , // 8
	VK_SELECT	 , // 9
	VK_FL		 , // 10
	VK_FR		 , // 11
	VK_FA		 , // 12
	VK_FB		 , // 13
	VK_FX		 , // 14
	VK_FY		 , // 15
	VK_VOL_UP	 , // 16
	VK_VOL_DOWN   , // 17
	VK_TAT		  // 18
};

/* The screen surface, joystick device */
SDL_Surface *screen = NULL;
SDL_Joystick *joy = NULL;

void Terminate(void)
{
	SDL_Quit();
#ifdef GP2X
	chdir("/usr/gp2x");
	execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
}

int main (int argc, char *argv[])
{
	int done;

	/* Initialize SDL */
	if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) {
		fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
		exit (1);
	}
	atexit (Terminate);

	SDL_ShowCursor(SDL_DISABLE);

	/* Set 320x240 16-bits video mode */
	screen = SDL_SetVideoMode (320, 240, 16, SDL_SWSURFACE);
	if (screen == NULL) {
		fprintf (stderr, "Couldn't set 320x240x16 video mode: %s\n", SDL_GetError ());
		exit (2);
	}

	/* Check and open joystick device */
	if (SDL_NumJoysticks() > 0) {
		joy = SDL_JoystickOpen(0);
		if(!joy) {
			fprintf (stderr, "Couldn't open joystick 0: %s\n", SDL_GetError ());
		}
	}

#ifdef GP2X
	/* Only use GP2X code here */
#endif

#ifdef WIN32
	/* Only use Windows code here */
#endif

	done = 0;
	while (!done)
	{
		SDL_Event event;

		/* Check for events */
		while (SDL_PollEvent (&event))
		{
			switch (event.type)
			{
				case SDL_KEYDOWN:
					/* if press Ctrl + C, terminate program */
					if ( (event.key.keysym.sym == SDLK_c) && (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) )
						done = 1;
					break;
				case SDL_KEYUP:
					break;
				case SDL_JOYBUTTONDOWN:
					/* if press Start button, terminate program */
					if ( event.jbutton.button == VK_START )
						done = 1;
					break;
				case SDL_JOYBUTTONUP:
					break;
				case SDL_QUIT:
					done = 1;
					break;
				default:
					break;
			}
		}

		/* Processing */
	}

	return 0;
}

Its just the standard template, but it won't compile. What needs to be changed?
 
Nothing should need change... sometimes you may accidentally screw something up by doing something you are sure has no effect but somehow does.

So you could try to re-extract it and such.

But if that doesn't work, after changing to gp2x mode, try pressing the Rebuild All button, next to the Build And Run button.

Hope this helps.
 
Back
Top