SDL2 on the PSP

Hi,

So… in a moment of madness whilst fiddling with my PSP I wondered if it was possible to use the current stable release rather than the fairly old one that builds with the psptoolchain.

I grabbed the code and after a few tweaks it happily seemed to build using Makefile.psp, I copied the various files into the correct locations where the rest of my psptoolchain lives.

Following some SDL2 tutorial, I wrote a simple app that opens a window on my Linux machine and fills it with a white rectangle. I then adapted it to work on the PSP. All seemed to work reasonably well, but I was unhappy with the build process. I liked the idea that I could update the psp toolchain so that it could build SDL 2.0.3 and install it into the correct locations just like it does with SDL 1.2

I took a look at the pspsdk and how it handles SDL1.2, it has the standard source, but then patches a few things (mostly configure.in) and uses a fairly normal build process using the main Makefile. I applied the parts of these patches that seemed to make sense and managed to compile everything (well almost everything the fuzzer test doesn’t work, but I ignored that for the moment). I can see that it also created libraries similarly to when I used Makefile.psp. Another bonus was that make instal/uninstall work fine and copy the correct things into the correct places within the psp toolchain.

But alas, I have failed at the final hurdle. My test program now fails to build and I am unable to work out why. The output of trying to build my test is as follows, but I don’t really understand what the error is telling me, so i’m hoping someone can help. As I said, using Makefile.psp the created library works fine, so I assume there’s some slight difference with the library created in the new way, probably some misunderstanding around how the default Makefile builds the library against the much simpler way that Makefile.psp does it.

The error:
root at kira:~/test# make -f Makefile.psp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra -Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2 -Dmain=SDL_main -G 16 -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra -Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2 -Dmain=SDL_main -G 16 -D_PSP_FW_VERSION=371 -c -o main.o main.cpp
main.cpp:9:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
main.cpp:9:5: warning: unused parameter ‘args’ [-Wunused-parameter]
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra -Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2 -Dmain=SDL_main -G 16 -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra -Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2 -Dmain=SDL_main -G 16 -D_PSP_FW_VERSION=371 -c -o Game.o Game.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra -Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2 -Dmain=SDL_main -G 16 -D_PSP_FW_VERSION=371 -L. -L/usr/local/pspdev/psp/sdk/lib -specs=/usr/local/pspdev/psp/sdk/lib/prxspecs -Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx main.o Game.o /usr/local/pspdev/psp/sdk/lib/prxexports.o -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL2 -Wl,–no-undefined -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -L/usr/local/pspdev/psp -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lpsputility -lpspnet_inet -lc -lpspuser -lSDL2 -lm -lpspgu -lGL -lpspaudio -lpspvram -lpspvfpu -lpsprtc -lpsphprm -I/usr/local/pspdev/psp/include -lstdc++ -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o Test.elf
/usr/local/pspdev/psp/lib/libSDL2.a(SDL_thread.o): In function SDL_TLSGet': /root/SDL2-2.0.3/src/thread/SDL_thread.c:44: undefined reference toSDL_SYS_GetTLSData’
/usr/local/pspdev/psp/lib/libSDL2.a(SDL_thread.o): In function SDL_TLSSet': /root/SDL2-2.0.3/src/thread/SDL_thread.c:60: undefined reference toSDL_SYS_GetTLSData’
/root/SDL2-2.0.3/src/thread/SDL_thread.c:75: undefined reference to SDL_SYS_SetTLSData' /usr/local/pspdev/psp/lib/libSDL2.a(SDL_thread.o): In functionSDL_TLSCleanup’:
/root/SDL2-2.0.3/src/thread/SDL_thread.c:90: undefined reference to SDL_SYS_GetTLSData' /root/SDL2-2.0.3/src/thread/SDL_thread.c:98: undefined reference toSDL_SYS_SetTLSData’
collect2: ld returned 1 exit status
/usr/local/pspdev/psp/sdk/lib/build.mak:176: recipe for target ‘Test.elf’ failed
make: *** [Test.elf] Error 1

Any help/thoughts/suggestions greatly appreciated.

This linker error is because the definition of SDL_SYS_GetTLSData() and the
other PSP-specific TLS (thread-local storage) functions are missing. Take
a look at either the generic or pthread TLS functions
(i.e. src/thread/pthread/SDL_systls.c). Someone would have to create a PSP
version of that SDL_systls.c file in order for this to link properly.

Jonny DOn Fri, Feb 6, 2015 at 6:39 PM, ashak <gary_libsdl at dsnine.co.uk> wrote:

Hi,

So… in a moment of madness whilst fiddling with my PSP I wondered if it
was possible to use the current stable release rather than the fairly old
one that builds with the psptoolchain.

I grabbed the code and after a few tweaks it happily seemed to build using
Makefile.psp, I copied the various files into the correct locations where
the rest of my psptoolchain lives.

Following some SDL2 tutorial, I wrote a simple app that opens a window on
my Linux machine and fills it with a white rectangle. I then adapted it to
work on the PSP. All seemed to work reasonably well, but I was unhappy with
the build process. I liked the idea that I could update the psp toolchain
so that it could build SDL 2.0.3 and install it into the correct locations
just like it does with SDL 1.2

I took a look at the pspsdk and how it handles SDL1.2, it has the standard
source, but then patches a few things (mostly configure.in) and uses a
fairly normal build process using the main Makefile. I applied the parts of
these patches that seemed to make sense and managed to compile everything
(well almost everything the fuzzer test doesn’t work, but I ignored that
for the moment). I can see that it also created libraries similarly to when
I used Makefile.psp. Another bonus was that make instal/uninstall work fine
and copy the correct things into the correct places within the psp
toolchain.

But alas, I have failed at the final hurdle. My test program now fails to
build and I am unable to work out why. The output of trying to build my
test is as follows, but I don’t really understand what the error is telling
me, so i’m hoping someone can help. As I said, using Makefile.psp the
created library works fine, so I assume there’s some slight difference with
the library created in the new way, probably some misunderstanding around
how the default Makefile builds the library against the much simpler way
that Makefile.psp does it.

The error:
root at kira:~/test# make -f Makefile.psp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra
-Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2
-Dmain=SDL_main -G 16 -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra
-Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2
-Dmain=SDL_main -G 16 -D_PSP_FW_VERSION=371 -c -o main.o main.cpp
main.cpp:9:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
main.cpp:9:5: warning: unused parameter ‘args’ [-Wunused-parameter]
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra
-Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2
-Dmain=SDL_main -G 16 -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra
-Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2
-Dmain=SDL_main -G 16 -D_PSP_FW_VERSION=371 -c -o Game.o Game.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wextra
-Wl,–no-as-needed -DPSP -I/usr/local/pspdev/psp/include/SDL2
-Dmain=SDL_main -G 16 -D_PSP_FW_VERSION=371 -L.
-L/usr/local/pspdev/psp/sdk/lib
-specs=/usr/local/pspdev/psp/sdk/lib/prxspecs
-Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx main.o Game.o
/usr/local/pspdev/psp/sdk/lib/prxexports.o -L/usr/local/pspdev/psp/lib
-lSDLmain -lSDL2 -Wl,–no-undefined -lm -lGL -lpspvfpu
-L/usr/local/pspdev/psp/sdk/lib -L/usr/local/pspdev/psp -lpspdebug -lpspgu
-lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio
-lpsputility -lpspnet_inet -lc -lpspuser -lSDL2 -lm -lpspgu -lGL -lpspaudio
-lpspvram -lpspvfpu -lpsprtc -lpsphprm -I/usr/local/pspdev/psp/include
-lstdc++ -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet
-lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser
-lpspkernel -o Test.elf
/usr/local/pspdev/psp/lib/libSDL2.a(SDL_thread.o): In function
SDL_TLSGet': /root/SDL2-2.0.3/src/thread/SDL_thread.c:44: undefined reference toSDL_SYS_GetTLSData’
/usr/local/pspdev/psp/lib/libSDL2.a(SDL_thread.o): In function
SDL_TLSSet': /root/SDL2-2.0.3/src/thread/SDL_thread.c:60: undefined reference toSDL_SYS_GetTLSData’
/root/SDL2-2.0.3/src/thread/SDL_thread.c:75: undefined reference to
SDL_SYS_SetTLSData' /usr/local/pspdev/psp/lib/libSDL2.a(SDL_thread.o): In functionSDL_TLSCleanup’:
/root/SDL2-2.0.3/src/thread/SDL_thread.c:90: undefined reference to
SDL_SYS_GetTLSData' /root/SDL2-2.0.3/src/thread/SDL_thread.c:98: undefined reference toSDL_SYS_SetTLSData’
collect2: ld returned 1 exit status
/usr/local/pspdev/psp/sdk/lib/build.mak:176: recipe for target 'Test.elf’
failed
make: *** [Test.elf] Error 1

Any help/thoughts/suggestions greatly appreciated.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks Jonny D,

I just configured SDL with --enable-threads=no and now I can build my test project. So that’s a start.

Perhaps i’ll try to take a look at what you’ve mentioned and see if I can work out how to do it. I’m a little new to all this though, so i’m not expecting to achieve anything :slight_smile: