Last updated: 16 march 2014
This page details how to compile your SDL program written in C/C++ for the PSP. It came into existence because of the lack of a complete guide.
No changes are necessary if your source code is written exclusively in C.
If you use C++ for the file where your
main() is declared, the compiler will complain: "no sceModuleInfo section found". This section it's trying to find is usually added through the
MODULE_INFO macro. However, adding one will not solve the underlying problem.
The problem is that the C++ compiler can't find your
main(), because it's a C function. To solve this, tag it as such, like so:
extern "C" int main(int argc, char* args)
main() found, SDLmain will be succesfully linked, which also adds the
sceModuleInfo section that the compiler was complaining about in the first place.
We'll use the makefile of the controller sample that ships with the SDK as a base:
TARGET = controller_basic
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Basic controller sample
PSPSDK=$(shell psp-config --pspsdk-path)
The documentation supplied with the PSP port of SDL instructs to add the following lines above the final include:
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
However, this setup has PSPBIN pointing to the wrong directory. Below the PSPSDK definition, add the following:
PSPDEV=$(shell psp-config -d)
Then change the PSPBIN definition to the following:
PSPBIN = $(PSPDEV)/bin
Finally, we need to add some libraries. stdc++ is required for a C++ program. pspirkeyb and psppower are required by SDL (for some reason the configuration script doesn't add them by itself). Add the following line to add them:
LIBS += -lstdc++ -lpspirkeyb -lpsppower
Customise the makefile for your project by adding the required object files, and change the eboot title to something appropriate.
Before you run make, though, here is some information that might save you some time:
printf()doesn't work. Use
pspDebugScreenPrintf()instead, which has the same syntax. Windows users: this won't output to a text file called stdout.txt, but to the screen. Hence it's only useful for debugging issues that crop up before the video mode is set.
BUILD_PRX=1to your makefile to generate a PRX file for use with PSP emulators.
PSP_LARGE_MEMORY=1to your makefile.
Thanks to protomank for contributing some of this information.