Would appreciate some help with SDL and PSP

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Arkanoid2520
Posts: 3
Joined: Thu Nov 26, 2009 8:11 am

Would appreciate some help with SDL and PSP

Post by Arkanoid2520 »

I've been trying to set this up for a while now and it's extremely frustrating coming across error after error. I'm setting this up on ubuntu 9.10 and I even started the process over on a clean install. I got from the svn the psptoolchain,psplibraries, and then got sdl. I read the readmes of each for ubuntu and the readme.psp for the sdl. Everything compiled and installed correctly.

Now when I try to compile:

Mind you for int main, I've tried SDL_main(etc) extern "c" SDL_main(etc) and about every combination of SDL_main and main.
#include <pspkernel.h>
#include <pspdebug.h>
#include "SDL/SDL.h"

#define printf pspDebugScreenPrintf

/* Define the module info section */
PSP_MODULE_INFO("template", 0, 1, 1);

/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
extern int main(int argc, char *argv[]);
int main(int argc, char *argv[])
{

pspDebugScreenInit();
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface* image;
SDL_Surface* background;
image = SDL_LoadBMP("hello.bmp");
background = SDL_SetVideoMode(480,272,24,SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE);
SDL_Rect offset;
offset.x = 0;
offset.y = 0;
SDL_BlitSurface(image,NULL,background,&offset);
pspDebugScreenPrintf("Hello World\n");

return 0;
}
Compiled with this makefile:

Again trying anything that would work theres just a ton of things added in here:
TARGET = Ohaspii
OBJS = main.o
PSPSDK = $(shell psp-config --pspsdk-path)
PSPDEV = $(shell psp-config -d)
PSPBIN = $(PSPDEV)/bin
SDL_CONFIG = /usr/local/pspdev/psp/bin/sdl-config

CFLAGS = -O2 -G0 -Wall -D PSP
CFLAGS += $(shell $(SDL_CONFIG) --cflags)$(shell $(SDL_CONFIG) --cflags)
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBS= -lSDL -lSDL_ttf -lSDL_image -lpspirkeyb -lpspwlan -lpsppower -lGL -l freetype -ljpeg -lpng -lz -lm -lSDL -lpspgu -l psphprm -lpspaudio -lstdc++ -lpspvfpu -lpsprtc -lpspge
LIBS += -lpspaudiolib -lpspaudio -lpsppower

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Ohaspii

include $(PSPSDK)/lib/build.mak
I get the error:
/usr/local/pspdev/lib/gcc/psp/4.3.2/../../../../psp/lib/crt0.o: In function `_main':
/home/arkanoid/tmp/toolchain/psptoolchain/build/pspsdk/src/startup/crt0.c:86: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [Ohaspii.elf] Error 1
I searched around for the answer to the problem but there were very few results and the few that I did find didn't help.
I'm trying to write this in c++. I know that there are better things to be using than SDL. I'm only doing this because I happen to be learning SDL for other things and thought it would be interesting to compile somethings on the PSP. I'm not too familiar with Linux but I would really appreciate it if someone could help me get this compiled.

For what its worth, heres my bashrc environments I added:
export PSPDEV="/usr/local/pspdev"
export PSPSDK="/usr/local/pspdev/psp/sdk"
export PATH="$PATH:/usr/local/pspdev/bin:/usr/local/pspdev/psp/bin"
There were also about 4 sdl-configs found on my computer in:

/usr/bin/
/usr/local/pspdev/bin
/usr/local/pspdev/psp/bin

And when I would sdl-config --prefix it would link to the one in /usr/bin/ so I renamed that one sdl-config2 so that it would read the one in /usr/local/pspdev/bin. The error I have happened before I did this, just thought I'd mention everything I can to pinpoint the problem.
Draan
Posts: 48
Joined: Sat Oct 17, 2009 3:39 am

Post by Draan »

Code: Select all

extern "C" int SDL_main &#40;int argc, char* args&#91;&#93;&#41;;

int SDL_main &#40;int argc, char* args&#91;&#93;&#41;
SDL_main - instead of your main function. And it should work.
Arkanoid2520
Posts: 3
Joined: Thu Nov 26, 2009 8:11 am

Post by Arkanoid2520 »

Draan wrote:

Code: Select all

extern "C" int SDL_main &#40;int argc, char* args&#91;&#93;&#41;;

int SDL_main &#40;int argc, char* args&#91;&#93;&#41;
SDL_main - instead of your main function. And it should work.
Ive already stated that I have tried that. Ive tried everything from
int main(int argc, char *argv[])

extern "c" int main(int argc, char *argv[])

int SDL_main(int argc, char *argv[])

extern "c" int SDL_main(int argc, char *argv[])
jsharrad
Posts: 100
Joined: Thu Oct 20, 2005 3:06 am

Post by jsharrad »

When I used SDL, I used my own main function.

Code: Select all

CFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags | sed s/-Dmain=SDL_main//&#41; 
LIBS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs | sed s/-lSDLmain//&#41;
Where PSPBIN is /usr/local/pspdev/psp/bin

If you want to use SDLmain you have to link -lSDLmain
Arkanoid2520
Posts: 3
Joined: Thu Nov 26, 2009 8:11 am

Post by Arkanoid2520 »

jsharrad wrote:When I used SDL, I used my own main function.

Code: Select all

CFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags | sed s/-Dmain=SDL_main//&#41; 
LIBS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs | sed s/-lSDLmain//&#41;
Where PSPBIN is /usr/local/pspdev/psp/bin

If you want to use SDLmain you have to link -lSDLmain
Thanks! That worked, this is always exciting seeing stuff you write run on a console/handheld.
Post Reply