forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Would appreciate some help with SDL and PSP

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Arkanoid2520



Joined: 26 Nov 2009
Posts: 3

PostPosted: Thu Nov 26, 2009 8:25 am    Post subject: Would appreciate some help with SDL and PSP Reply with quote

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.
Quote:
#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:
Quote:
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:
Quote:
/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:
Quote:
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.
Back to top
View user's profile Send private message
Draan



Joined: 17 Oct 2009
Posts: 55

PostPosted: Fri Nov 27, 2009 12:14 am    Post subject: Reply with quote

Code:

extern "C" int SDL_main (int argc, char* args[]);

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


SDL_main - instead of your main function. And it should work.
Back to top
View user's profile Send private message
Arkanoid2520



Joined: 26 Nov 2009
Posts: 3

PostPosted: Fri Nov 27, 2009 12:59 am    Post subject: Reply with quote

Draan wrote:
Code:

extern "C" int SDL_main (int argc, char* args[]);

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


SDL_main - instead of your main function. And it should work.


Ive already stated that I have tried that. Ive tried everything from

Quote:
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[])
Back to top
View user's profile Send private message
jsharrad



Joined: 20 Oct 2005
Posts: 102

PostPosted: Fri Nov 27, 2009 1:13 am    Post subject: Reply with quote

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

Code:
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags | sed s/-Dmain=SDL_main//)
LIBS += $(shell $(PSPBIN)/sdl-config --libs | sed s/-lSDLmain//)


Where PSPBIN is /usr/local/pspdev/psp/bin

If you want to use SDLmain you have to link -lSDLmain
Back to top
View user's profile Send private message
Arkanoid2520



Joined: 26 Nov 2009
Posts: 3

PostPosted: Fri Nov 27, 2009 8:54 am    Post subject: Reply with quote

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

Code:
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags | sed s/-Dmain=SDL_main//)
LIBS += $(shell $(PSPBIN)/sdl-config --libs | sed s/-lSDLmain//)


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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group