joan88
15/07/2007, 23:43
Hola a todos, estoy intentando aprender a programar para la gp2x. Primero que nada he hecho un hello world con un bmp usando el siguiente codigo:
#include <SDL.h>
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_DEPTH 8
int main() {
SDL_Surface *screen;
SDL_Surface *bmp;
SDL_Rect targetarea;
/*Inicializar SDL */
SDL_Init(SDL_INIT_VIDEO);
/* Inicializar pantalla / window */
screen=SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SDL_SWSURFACE);
/* Load test.bmp */
bmp = SDL_LoadBMP("test.bmp");
/* Draw the image to 10, 20 */
targetarea.x=10;
targetarea.y=20;
targetarea.w=bmp->w;
targetarea.h = bmp->h;
SDL_BlitSurface(bmp, NULL, screen, &targetarea);
/* Actualizar la pantalla (doble buffer) */
SDL_Flip(screen);
while(1);
}
Este codigo compila perfectamente para pc, uso ubuntu 7.04, para compilarlo he hecho: gcc -o world world.c -lSDL y al ejecutar ./world sale la imagen bmp. Hasta aqui todo bien :)
Ahora lo quiero compilar para gp2x y vienen los problemas. Como el titulo dice uso un toolchain de uncanny.
Para instalar el toolchain he descargado el archivo .tgz lo he descomprimido con un tar xzf toolchain-uncanny.tgz me ha creado un directorio llamado gp2xdev y por último he movido el directorio a /home/joan/gp2xdev.
El Makefile que uso es el que sigue:
TOOLCHAIN = /home/joan/gp2xdev
CROSS_COMPILE = $(TOOLCHAIN)/bin/arm-linux-
SDL_BASE = $(TOOLCHAIN)/bin/arm-linux-
LDFLAGS = -static
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
STRIP = $(CROSS_COMPILE)strip
CFLAGS = -I$(TOOLCHAIN)/include/SDL -O2 -Wall
CXXFLAGS = -I$(TOOLCHAIN)/include/SDL -DTARGET_GP2X -O2 -Wall
LIBS = -L $(TOOLCHAIN)/lib -lz -lm -lpthread -lSDL
TARGET = world.gpe
OBJS = world.o
ALL_TARGETS = $(TARGET)
all: $(ALL_TARGETS)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
$(STRIP) $(TARGET)
clean:
rm -f $(ALL_TARGETS) *.o
El problema viene al hacer un make xD, que mi consolita me lanza esto:
/home/joan/gp2xdev/bin/arm-linux-gcc -static -o world.gpe world.o -L /home/joan/gp2xdev/lib -lz -lm -lpthread -lSDL
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `RunThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:83: undefined reference to `pthread_exit'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_CreateThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:92: undefined reference to `pthread_attr_init'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:96: undefined reference to `pthread_attr_setdetachstate'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:99: undefined reference to `pthread_create'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_SetupThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:117: undefined reference to `pthread_sigmask'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:123: undefined reference to `pthread_setcanceltype'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_ThreadID':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:131: undefined reference to `pthread_self'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_WaitThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:136: undefined reference to `pthread_join'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_KillThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:142: undefined reference to `pthread_cancel'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_CreateSemaphore':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:103: undefined reference to `sem_init'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_DestroySemaphore':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:129: undefined reference to `sem_destroy'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemTryWait':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:144: undefined reference to `sem_trywait'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemWait':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:165: undefined reference to `sem_wait'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemValue':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:209: undefined reference to `sem_getvalue'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemPost':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:230: undefined reference to `sem_post'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_CreateMutex':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:72: undefined reference to `pthread_mutexattr_init'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:77: undefined reference to `pthread_mutexattr_setkind_np'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:82: undefined reference to `pthread_mutex_init'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_DestroyMutex':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:96: undefined reference to `pthread_mutex_destroy'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexP':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:133: undefined reference to `pthread_mutex_lock'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexV':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:171: undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
make: *** [world.gpe] Error 1
¿La pregunta es que pasa? a mi parecer parece que busque las librerias en un sitio incorrecto en /home/darius/gp2x.... en lugar de /home/joan/gp2xdev...
¿o que ocurre? Gracias por adelantado y salu2 a todos los miembros de esta comunidad :lovegp2x: :brindis:
< - >
EDITO1:Bueno asunto solucionado la solucion es que el orden de los factores si altera el producto. En el make en lugar de
LIBS = -L $(TOOLCHAIN)/lib -lz -lm -lpthread -lSDL
tiene que ser:
LIBS = -L $(TOOLCHAIN)/lib -lSDL -lz -lm -lpthread
Gracias a misato por todo :). Salu2
EDITO2: he borrado el link :)
#include <SDL.h>
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_DEPTH 8
int main() {
SDL_Surface *screen;
SDL_Surface *bmp;
SDL_Rect targetarea;
/*Inicializar SDL */
SDL_Init(SDL_INIT_VIDEO);
/* Inicializar pantalla / window */
screen=SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SDL_SWSURFACE);
/* Load test.bmp */
bmp = SDL_LoadBMP("test.bmp");
/* Draw the image to 10, 20 */
targetarea.x=10;
targetarea.y=20;
targetarea.w=bmp->w;
targetarea.h = bmp->h;
SDL_BlitSurface(bmp, NULL, screen, &targetarea);
/* Actualizar la pantalla (doble buffer) */
SDL_Flip(screen);
while(1);
}
Este codigo compila perfectamente para pc, uso ubuntu 7.04, para compilarlo he hecho: gcc -o world world.c -lSDL y al ejecutar ./world sale la imagen bmp. Hasta aqui todo bien :)
Ahora lo quiero compilar para gp2x y vienen los problemas. Como el titulo dice uso un toolchain de uncanny.
Para instalar el toolchain he descargado el archivo .tgz lo he descomprimido con un tar xzf toolchain-uncanny.tgz me ha creado un directorio llamado gp2xdev y por último he movido el directorio a /home/joan/gp2xdev.
El Makefile que uso es el que sigue:
TOOLCHAIN = /home/joan/gp2xdev
CROSS_COMPILE = $(TOOLCHAIN)/bin/arm-linux-
SDL_BASE = $(TOOLCHAIN)/bin/arm-linux-
LDFLAGS = -static
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
STRIP = $(CROSS_COMPILE)strip
CFLAGS = -I$(TOOLCHAIN)/include/SDL -O2 -Wall
CXXFLAGS = -I$(TOOLCHAIN)/include/SDL -DTARGET_GP2X -O2 -Wall
LIBS = -L $(TOOLCHAIN)/lib -lz -lm -lpthread -lSDL
TARGET = world.gpe
OBJS = world.o
ALL_TARGETS = $(TARGET)
all: $(ALL_TARGETS)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
$(STRIP) $(TARGET)
clean:
rm -f $(ALL_TARGETS) *.o
El problema viene al hacer un make xD, que mi consolita me lanza esto:
/home/joan/gp2xdev/bin/arm-linux-gcc -static -o world.gpe world.o -L /home/joan/gp2xdev/lib -lz -lm -lpthread -lSDL
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `RunThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:83: undefined reference to `pthread_exit'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_CreateThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:92: undefined reference to `pthread_attr_init'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:96: undefined reference to `pthread_attr_setdetachstate'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:99: undefined reference to `pthread_create'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_SetupThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:117: undefined reference to `pthread_sigmask'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:123: undefined reference to `pthread_setcanceltype'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_ThreadID':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:131: undefined reference to `pthread_self'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_WaitThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:136: undefined reference to `pthread_join'
/home/joan/gp2xdev/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_KillThread':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_systhread.c:142: undefined reference to `pthread_cancel'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_CreateSemaphore':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:103: undefined reference to `sem_init'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_DestroySemaphore':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:129: undefined reference to `sem_destroy'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemTryWait':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:144: undefined reference to `sem_trywait'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemWait':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:165: undefined reference to `sem_wait'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemValue':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:209: undefined reference to `sem_getvalue'
/home/joan/gp2xdev/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemPost':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_syssem.c:230: undefined reference to `sem_post'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_CreateMutex':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:72: undefined reference to `pthread_mutexattr_init'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:77: undefined reference to `pthread_mutexattr_setkind_np'
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:82: undefined reference to `pthread_mutex_init'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_DestroyMutex':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:96: undefined reference to `pthread_mutex_destroy'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexP':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:133: undefined reference to `pthread_mutex_lock'
/home/joan/gp2xdev/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexV':
/home/darius/gp2x/sdl/SDL-1.2.9/src/thread/SDL_sysmutex.c:171: undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
make: *** [world.gpe] Error 1
¿La pregunta es que pasa? a mi parecer parece que busque las librerias en un sitio incorrecto en /home/darius/gp2x.... en lugar de /home/joan/gp2xdev...
¿o que ocurre? Gracias por adelantado y salu2 a todos los miembros de esta comunidad :lovegp2x: :brindis:
< - >
EDITO1:Bueno asunto solucionado la solucion es que el orden de los factores si altera el producto. En el make en lugar de
LIBS = -L $(TOOLCHAIN)/lib -lz -lm -lpthread -lSDL
tiene que ser:
LIBS = -L $(TOOLCHAIN)/lib -lSDL -lz -lm -lpthread
Gracias a misato por todo :). Salu2
EDITO2: he borrado el link :)