Compiling an SDL program written in C/C++ for the PSP

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.

Source code changes


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[])

With your 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


PSP_EBOOT_TITLE = Basic controller sample

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

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:


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

Now what?

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:

Thanks to protomank for contributing some of this information.