Problem With Sdl_gfx


BadKarma

Still Fresh
Joined
Sep 10, 2006
Messages
13
I'm trying to compile simple program for GP2X - I'm using GP2XSDK in Windows with DevCpp
This program only draws 2 lines (with SDL+SDL-gfx), waits few seconds and finishes.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cstring>
using namespace std;
#include "SDL\SDL.h"
#include "SDL\SDL_gfxPrimitives.h"

int main( int argc, char* args[] )
{

	SDL_Surface *screen;
	if (SDL_Init( SDL_INIT_VIDEO )<0)  {cout<<"Video mode initialization FAILED !";return 1;}
	screen = SDL_SetVideoMode( 320, 240, 16, SDL_SWSURFACE);  if (!screen){cout<<"Couldn't set video mode";return 1;}
	
	lineRGBA(screen, 0, 0, 320, 240, 120,120,120,255);
	lineRGBA(screen, 0, 240, 320, 0, 120,120,120,255);
	
	
	SDL_Flip(screen);
	SDL_Delay(2000);
	SDL_Quit();
   
	return 0;	
}

In DevCpp I have 2 compilers profiles - win and gp2x. I am able to compile .exe and run it so sdl_gfx runs OK in windows.

When I tried gp2x compiler profile with "lineRGBA..." lines commented it created .gpe and it ran OK on GP2X, when these lines are not commented error msg appears :

" [Linker error] undefined reference to `lineRGBA' " (path to gfx libraries and header files is correct)

I tried to replace libsdl_gfx.* libraries with theoddbot-libs but there was error - it said my program used hardware FP and these libraries use software FP

My compiler & linker parameters :

-static -lpthread -lm -DGP2X
-lmingw32 -lSDLmain -lSDL -lSDL_gfx


Thanks for any ideas....
 
Last edited by a moderator:
Hello everybody :)

I have the same kind of problem trying to compile my project with the GPH SDK.

The compilation works when I choose 'win' since I added -l SDL_gfx in the linker options, but when I'm trying to compile for the GP2X, I got this message from the compilator : cannot find -lSDL_gfx

Is there anything else to do before compiling for the GP2X using the SDL_gfx libraries ?

Thank you :)
 
Here's the Makefile I use to compile my SDL_gfx programs. Pay special attention to the GPLDFLAGS variable and how it uses -static and also `$(GP2XDEV)/bin/sdl-config --static-libs`. This Makefile has served me very well. If you don't know make then the line to compile a single file as a result of this is:

arm-open2x-linux-gcc -c -Wall -O3 -DNO_FLOAT -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --cflags` -DGP2X main.c -o main.o

CODE

GP2XDEV=/opt/open2x/gcc-4.1.1-glibc-2.3.6
PATH+=:$(GP2XDEV)/bin
LD_LIBRARY_PATH=$(GP2XDEV)/lib

CFLAGS=-c -Wall
LDFLAGS=-lm -lg -lpthread `sdl-config --libs` -lSDL_gfx
GPLDFLAGS=-lSDL_gfx -static `$(GP2XDEV)/bin/sdl-config --static-libs`
SOURCES=main.c
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLEPC=perf_test
EXECUTABLEGP=perf_test_gp2x
DEST=.

ifdef arm
CC=arm-open2x-linux-gcc
CFLAGS+=-O3 -DNO_FLOAT -I$(GP2XDEV)/include \
`$(GP2XDEV)/bin/sdl-config --cflags` -DGP2X
else
CC=gcc
CFLAGS+=-g -DDEBUG `sdl-config --cflags`
endif

all:
make cleanobjs
make pc
make cleanobjs
make arm=1 gp
make cleanobjs

pc: $(SOURCES) $(EXECUTABLEPC)

gp: $(SOURCES) $(EXECUTABLEGP)

$(EXECUTABLEPC): $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) -o $(DEST)/$@

$(EXECUTABLEGP): $(OBJECTS)
$(CC) $(OBJECTS) -o $(DEST)/$@ $(GPLDFLAGS)

.c.o:
$(CC) $(CFLAGS) $< -o $@

cleanobjs:
rm -f $(OBJECTS)

clean:
-rm -f $(DEST)/wire3d $(DEST)/.gpe *~ *.o
 
Back
Top