GP2X Any Other Solution Than Sdl?


You can use SDL.. or use rlyehs minilib.. or use a direct standard Linux framebuffer .. or talk direct to the hardware. All are pretty easy :)

jeff
 
They dont seem easy to me, I have installed multiple toolchains with the same results.

If I link statically SDL yells about pthreads (an both Open2x and DevKitPro). If I dont then it compiles fine but doesnt work on the actual GP2x, and in the case of Open2x, the SDL libs look for a specific version of libpng, libz, and libjpeg, (the precompiled libs for Open2x toolchain have different versions) and I dont know if creating symlinks to trick it into using a different version, will work right.

And lastly, the SDL headers have errors in them if I use C++, so its plain C.

This stopped being fun hours ago.

Anyone have the slightest clue why its not working?

I downloaded
arm-open2x-linux-apps-gcc-4.1.1-glibc-2.3.6_i686_linux.tar.bz2
Installed it as per directions, then downloaded
open2x-libpack-20071903-gcc-4.1.1-glibc-2.3.6.tar.bz2
an unpacked it where it would place its files properly.

And when I compile it with this command
/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/arm-open2x-linux-gcc -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include/SDL -L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib -o main main.c -lSDLmain -lSDL -lSDL_image -lSDL_gfx
I get
QUOTE
libjpeg.so.62, needed by /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL_image.so, not found

(And more) Errors, because SDL is looking for a version of the libs (previously named) that dont exist.

If I add -static to the compile line, I get
QUOTE
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexV':
SDL_sysmutex.c:(.text+0x14): undefined reference to `pthread_mutex_unlock'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexP':
Etc.....

I am hopelessly lost...
 
Open2x and Oopo's certainly do, and I'm fairly certain DevKitGP2X does too. If it doesn't work on those, you are doing something else wrong with your linking.
 
Oh I found pthreads, the toolchain, for some reason, has two sets of libs, one where you would normally expect to find them /opt/open2x/gcc-4.1.1-glibc-2.3.6/lib (where practically every lib is, even the SDL lib got installed there) and one in a arch specific directory /opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib, however linking to this, gives the same results, as if it were not being linked at all.

Does anyone have an basic example (like what I posted) with the exact command line used to compile, with Open2k installed as per instructions, using SDL, that they can upload?

If I am doing something wrong, please correct me, I have pasted my compile command multiple times. Here it is revised to find the pthreads.

/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/arm-open2x-linux-gcc -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include/SDL -L/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib -L/opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/lib -o main main.c -lpthread -lSDLmain -lSDL -lSDL_image -lSDL_gfx -static

Here is the error output when compiled:

QUOTE
./compile_gp2x.sh
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexV':
SDL_sysmutex.c:(.text+0x14): undefined reference to `pthread_mutex_unlock'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_mutexP':
SDL_sysmutex.c:(.text+0x74): undefined reference to `pthread_mutex_lock'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_DestroyMutex':
SDL_sysmutex.c:(.text+0xcc): undefined reference to `pthread_mutex_destroy'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_sysmutex.o): In function `SDL_CreateMutex':
SDL_sysmutex.c:(.text+0x108): undefined reference to `pthread_mutexattr_init'
SDL_sysmutex.c:(.text+0x114): undefined reference to `pthread_mutexattr_setkind_np'
SDL_sysmutex.c:(.text+0x120): undefined reference to `pthread_mutex_init'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_KillThread':
SDL_systhread.c:(.text+0x4): undefined reference to `pthread_cancel'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_WaitThread':
SDL_systhread.c:(.text+0x10): undefined reference to `pthread_join'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_systhread.o): In function `SDL_ThreadID':
SDL_systhread.c:(.text+0x14): undefined reference to `pthread_self'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_SetupThread':
SDL_systhread.c:(.text+0x60): undefined reference to `pthread_sigmask'
SDL_systhread.c:(.text+0x6c): undefined reference to `pthread_setcanceltype'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_systhread.o): In function `SDL_SYS_CreateThread':
SDL_systhread.c:(.text+0x9c): undefined reference to `pthread_attr_init'
SDL_systhread.c:(.text+0xb0): undefined reference to `pthread_attr_setdetachstate'
SDL_systhread.c:(.text+0xc8): undefined reference to `pthread_create'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_systhread.o): In function `RunThread':
SDL_systhread.c:(.text+0x128): undefined reference to `pthread_exit'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemPost':
SDL_syssem.c:(.text+0x24): undefined reference to `sem_post'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemValue':
SDL_syssem.c:(.text+0x7c): undefined reference to `sem_getvalue'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemWait':
SDL_syssem.c:(.text+0xbc): undefined reference to `sem_wait'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_syssem.o): In function `SDL_SemTryWait':
SDL_syssem.c:(.text+0x110): undefined reference to `sem_trywait'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_syssem.o): In function `SDL_DestroySemaphore':
SDL_syssem.c:(.text+0x1cc): undefined reference to `sem_destroy'
/opt/open2x/gcc-4.1.1-glibc-2.3.6/lib/libSDL.a(SDL_syssem.o): In function `SDL_CreateSemaphore':
SDL_syssem.c:(.text+0x20c): undefined reference to `sem_init'
collect2: ld returned 1 exit status
 
Put -lpthread at the end - the order matters

i.e. the library has to be after the library complaining about this - in this case SDL
 
You're creating a screen with 2 buffers, writing to only one of them, and then you have a while loop that does nothing other than flip between your written to buffer and the empty one. You either need to write things to both buffers, or only call flip once to get things displayed then don't call it again in your loop.
 
Back
Top