Can't compile some SDL + OpenGL stuff ...

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

Moderators: cheriff, TyRaNiD

Post Reply
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Can't compile some SDL + OpenGL stuff ...

Post by gambiting »

Hi! I'm working on new game for NeoFlash Spring contest,and I can't compile my very early source :P.I guess I have all needed libs,so I don't know what's the problem.Also,the same source compiles to linux executable without problems.Errors I have are:

Code: Select all

gambiting@gambiting-desktop:~/psp_opengl$ make
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -fno-rtti -D_PSP_FW_VERSION=371   -c -o main.o main.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -fno-rtti -D_PSP_FW_VERSION=371   -c -o player.o player.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -fno-rtti -D_PSP_FW_VERSION=371   -c -o timer.o timer.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -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 player.o timer.o /usr/local/pspdev/psp/sdk/lib/prxexports.o -L/usr/local/pspdev/psp/lib -lSDL_ttf -lSDL -lSDL_gfx -lGL -lGLU -lm -lpspvfpu -L/usr/local/pspdev/psp/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpsppower -lfreetype -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o tankswar.psp.elf
main.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x7c): undefined reference to `std::ios_base::Init::Init()'
main.cpp:(.text+0x84): undefined reference to `std::ios_base::Init::~Init()'
/usr/local/pspdev/psp/lib/libGLU.a(gluPerspectivef.o): In function `gluPerspectivef':
/home/gambiting/psp/pspgl/gluPerspectivef.c:30: undefined reference to `glMultMatrixf'
collect2: ld returned 1 exit status
make: *** [tankswar.psp.elf] Error 1
gambiting@gambiting-desktop:~/psp_opengl$
Please help.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Ok,I repaired it - I removed glMultMatrixf from libriary source,and removed #include <iostream> from main.cpp - it wasn't needed.
But now I have much bigger problem - I want to run it through PSPLink,and all I get is:

Code: Select all

host0&#58;/> ./tankswar.psp.prx
Load/Start host0&#58;/tankswar.psp.prx UID&#58; 0x0427E067 Name&#58; "Tanks_war"
host0&#58;/> Exception - Bus error &#40;data&#41;
Thread ID - 0x0425E673
Th Name   - user_main
Module ID - 0x0427E067
Mod Name  - "Tanks_war"
EPC       - 0x08806744
Cause     - 0x1000001C
BadVAddr  - 0x40A00436
Status    - 0x20088613
zr&#58;0x00000000 at&#58;0x2008FF00 v0&#58;0x00FFFFFF v1&#58;0x00001D01
a0&#58;0x00000140 a1&#58;0x00000050 a2&#58;0x00000001 a3&#58;0x00010000
t0&#58;0x00000008 t1&#58;0x882F9100 t2&#58;0x00000000 t3&#58;0x088621A0
t4&#58;0x09FBFCD0 t5&#58;0x00001E04 t6&#58;0x0880EE54 t7&#58;0x20088600
s0&#58;0x00000001 s1&#58;0x09FBFE34 s2&#58;0x09FBFE30 s3&#58;0x09FBFEE0
s4&#58;0x00000018 s5&#58;0x00000013 s6&#58;0xDEADBEEF s7&#58;0xDEADBEEF
t8&#58;0x800201AB t9&#58;0x00000000 k0&#58;0x09FBFF00 k1&#58;0x00000000
gp&#58;0x08854CA0 sp&#58;0x09FBFD58 fp&#58;0x09FBFEA0 ra&#58;0x08804388
0x08806744&#58; 0x8C830008 '....' - lw         $v1, 8&#40;$a0&#41;
Also,I can see a cursor on a black screen,so I guess that at last SDL inits properly.When I start it from XMB it just hangs.Any ideas please?
I guess it's memory overflow,but this code at this stage ir VERY simple,and also I have build_prx=1 and PSP_HEAP_SIZE_MAX(); set.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

<double post,sorry>
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Try PSP_HEAP_SIZE_KB(20480) instead of PSP_HEAP_SIZE_MAX().
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Insert_witty_name wrote:Try PSP_HEAP_SIZE_KB(20480) instead of PSP_HEAP_SIZE_MAX().
Still the same error.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, you can either use the gdb for PSP in the sdk, or you can add prints to the screen (part of the debug code in the sdk). The print method is probably more popular, even on PCs. If you look through most programs, you'll find status prints all over. You'll find examples of using those debug prints in most PSP apps. It's pretty simple and works well enough for most devs.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

J.F. wrote:Well, you can either use the gdb for PSP in the sdk, or you can add prints to the screen (part of the debug code in the sdk). The print method is probably more popular, even on PCs. If you look through most programs, you'll find status prints all over. You'll find examples of using those debug prints in most PSP apps. It's pretty simple and works well enough for most devs.
Gdb debug gives:

Code: Select all

&#40;gdb&#41; continue
Continuing.
&#91;New thread 69690211&#93;

Program received signal SIGBUS, Bus error.
&#91;Switching to thread 69690211&#93;
0x08806744 in ?? &#40;&#41;
&#40;gdb&#41;
I will try to figure out where it hangs with some debug output.I will write when I solve it.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Ok,I figured out what's the problem,I made a debug statements like that:

Code: Select all

bool init_all&#40;&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;
	
    //Initialize SDL
	if&#40; SDL_Init&#40;SDL_INIT_VIDEO&#41; < 0 &#41;
	&#123;
		return false;    
	&#125;
	printf&#40;"\t SDL_INIT Done!\n"&#41;;
    
	if&#40; SDL_SetVideoMode&#40; SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_OPENGL&#41; == NULL &#41;
	&#123;
		return false;
	&#125;
	printf&#40;"\t SDL_setVideoMode Done!\n"&#41;;
    
    //Initialize OpenGL
	if&#40; init_GL&#40;&#41; == false &#41;
	&#123;
		return false;    
	&#125;
	printf&#40;"\t initGL Done!\n"&#41;;
    

    
	return true;    
&#125;
And,inside init_GL function:

Code: Select all

bool init_GL&#40;&#41;
&#123;
    //Set clear color
	
	printf&#40;"\t initializing ....\n"&#41;;
	glShadeModel&#40;GL_SMOOTH&#41;;
	printf&#40;"\t shade model Done!\n"&#41;;
	glClearColor&#40;0.0f, 0.0f, 0.0f, 0.5f&#41;;
	printf&#40;"\t clear color Done!\n"&#41;;
	glClearDepth&#40;1.0f&#41;;
	printf&#40;"\t clear depth!\n"&#41;;
	glEnable&#40;GL_DEPTH_TEST&#41;;
	printf&#40;"\t gl_depth_test Done!\n"&#41;;
	glDepthFunc&#40;GL_LEQUAL&#41;;
	printf&#40;"\t depth func Done!\n"&#41;;
	glMatrixMode&#40; GL_PROJECTION &#41;;
	printf&#40;"\t matrix mode Done!\n"&#41;;
	glLoadIdentity&#40;&#41;;
	printf&#40;"\t load identity Done!\n"&#41;;
	gluPerspective&#40;54.0f,&#40;GLfloat&#41;SCREEN_WIDTH/&#40;GLfloat&#41;SCREEN_HEIGHT,1.0f,1000.0f&#41;;
	printf&#40;"\t perspective Done!\n"&#41;;
	glMatrixMode&#40; GL_MODELVIEW &#41;;
	printf&#40;"\t model view2 Done!\n"&#41;;
	glLoadIdentity&#40;&#41;;
	printf&#40;"\t load identity 2 Done!\n"&#41;;
	SDL_GL_SetAttribute&#40; SDL_GL_RED_SIZE, 8 &#41;;
	SDL_GL_SetAttribute&#40; SDL_GL_GREEN_SIZE, 8 &#41;;
	SDL_GL_SetAttribute&#40; SDL_GL_BLUE_SIZE, 8 &#41;;
	SDL_GL_SetAttribute&#40; SDL_GL_ALPHA_SIZE, 8 &#41;;
	SDL_GL_SetAttribute&#40; SDL_GL_DEPTH_SIZE, 16 &#41;;
	SDL_GL_SetAttribute&#40; SDL_GL_DOUBLEBUFFER, 1 &#41;;
	printf&#40;"\t set atributes Done!\n"&#41;;
	//glHint&#40;GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST&#41;;
    
	if&#40; glGetError&#40;&#41; != GL_NO_ERROR &#41;
	&#123;
		return false;    
	&#125;
    
	return true;
&#125;
When I run it on PSP now,I can see:

Code: Select all

SDL_INIT Done!
SDL_setVideoMode Done!
initializing....
and then it hangs.So now I know that every simple OpenGl instruction will hang it - now the question is - why??? I thought that opengl is working fine on slim??
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Ok,I found on the other thread that I have to recompile SDL with sdl support( -DHAVE_OPENGL cflag set),so I did.Now it won't compile with such errors:

Code: Select all

gambiting@gambiting-desktop&#58;~/psp_opengl$ make
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -fno-rtti -D_PSP_FW_VERSION=371   -c -o main.o main.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -fno-rtti -D_PSP_FW_VERSION=371   -c -o player.o player.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -fno-rtti -D_PSP_FW_VERSION=371   -c -o timer.o timer.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -g -O2 -G0 -Wall -fno-exceptions -I/usr/local/pspdev/psp/include/SDL -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 player.o timer.o /usr/local/pspdev/psp/sdk/lib/prxexports.o -L/usr/local/pspdev/psp/lib -lglut -lGLU -lGL -lSDL_ttf -lSDL -lSDL_gfx -lm -lpspvfpu -lpspdisplay -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpsppower -lfreetype -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o tankswar.psp.elf
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58; In function `PSP_GL_Init'&#58;
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;109&#58; undefined reference to `eglGetDisplay'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;109&#58; undefined reference to `eglGetError'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;110&#58; undefined reference to `eglInitialize'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;110&#58; undefined reference to `eglGetError'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;135&#58; undefined reference to `eglChooseConfig'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;135&#58; undefined reference to `eglGetError'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;143&#58; undefined reference to `eglCreateContext'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;143&#58; undefined reference to `eglGetError'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;144&#58; undefined reference to `eglCreateWindowSurface'
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;144&#58; undefined reference to `eglGetError'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58; In function `PSP_GL_SwapBuffers'&#58;
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;82&#58; undefined reference to `eglSwapBuffers'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58; In function `PSP_GL_MakeCurrent'&#58;
/home/gambiting/psp/SDL/src/video/psp/SDL_pspgl.c&#58;69&#58; undefined reference to `eglMakeCurrent'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x14&#41;&#58; undefined reference to `glBlendFunc'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x44&#41;&#58; undefined reference to `glFlush'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x4c&#41;&#58; undefined reference to `glGenTextures'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x54&#41;&#58; undefined reference to `glGetString'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x6c&#41;&#58; undefined reference to `glOrtho'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x74&#41;&#58; undefined reference to `glPixelStorei'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x84&#41;&#58; undefined reference to `glPopClientAttrib'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0x9c&#41;&#58; undefined reference to `glPushClientAttrib'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0xac&#41;&#58; undefined reference to `glTexCoord2f'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0xb4&#41;&#58; undefined reference to `glTexEnvf'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0xc4&#41;&#58; undefined reference to `glTexParameteri'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0xcc&#41;&#58; undefined reference to `glTexSubImage2D'
/usr/local/pspdev/psp/lib/libSDL.a&#40;SDL_pspgl.o&#41;&#58;&#40;.rodata+0xd4&#41;&#58; undefined reference to `glVertex2i'
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;tankswar.psp.elf&#93; Error 1
gambiting@gambiting-desktop&#58;~/psp_opengl$
My makefile looks like this:

Code: Select all

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
PSPDIR=$&#40;shell psp-config --psp-prefix&#41;

SDLCFLAGS=-I/usr/local/pspdev/psp/include/SDL
SDLLIBS=-L/usr/local/pspdev/psp/lib -lglut -lGLU -lGL -lSDL_ttf -lSDL -lSDL_gfx -lm -lpspvfpu -lpspdisplay -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpsppower -lfreetype

TARGET = tankswar.psp
OBJS = main.o player.o timer.o

CFLAGS = -g -O2 -G0 -Wall -fno-exceptions $&#40;SDLCFLAGS&#41;
CXXFLAGS = $&#40;CFLAGS&#41; -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
PSP_FW_VERSION = 371

LIBS = $&#40;SDLLIBS&#41;
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Tanks War

include $&#40;PSPSDK&#41;/lib/build.mak 
PLEASE help!
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

Change the link order of your libraries, the LIBS line for DSP looks like:

LIBS= -lSDL_image -lSDL_mixer -lSDL -lGLU -lGL -lpng -ljpeg -lz -lm -lstdc++ -lc -lc -lpsputility -lpspdebug -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspvfpu -lpspuser -lpsprtc -lpsppower -lpspdebug -lpspge -lpspaudio -lpspctrl -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpsphprm -lpspsdk

DSP doesn't use freetype, slide that in around -lpng I think (assuming you are using it).
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Danzel,you are my god,aside Tyranid(and naturally Dark AleX).I've been working whole day to make it run,and it was that simple! Genius,genius I say...

Here's my makefile now If anyone wants it:

Code: Select all

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
PSPDIR=$&#40;shell psp-config --psp-prefix&#41;

SDLCFLAGS=-I/usr/local/pspdev/psp/include/SDL
LIBS= -lSDL -lGLU -lGL -lz -lm -lstdc++ -lc -lc -lpsputility -lpspdebug -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspvfpu -lpspuser -lpsprtc -lpsppower -lpspdebug -lpspge -lpspaudio -lpspctrl -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpsphprm -lpspsdk 

TARGET = tankswar.psp
OBJS = main.o player.o timer.o

CFLAGS = -g -O2 -G0 -Wall -fno-exceptions -DHAVE_OPENGL  $&#40;SDLCFLAGS&#41;
CXXFLAGS = $&#40;CFLAGS&#41; -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
PSP_FW_VERSION = 371

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Tanks War

include $&#40;PSPSDK&#41;/lib/build.mak 
harrysound
Posts: 1
Joined: Sat Oct 18, 2008 12:03 am

Post by harrysound »

Hi

Thanks to gambiting i succeeded to compile my first application that uses SDL and OpenGL !
Actually i had to add the following libs to build correctly : -lpspirkeyb -lpspkernel -lpsppower
Does anybody else needed to add these libs to build a SDL/GL app ?

cheers

Harry
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

harrysound wrote:Hi

Thanks to gambiting i succeeded to compile my first application that uses SDL and OpenGL !
Actually i had to add the following libs to build correctly : -lpspirkeyb -lpspkernel -lpsppower
Does anybody else needed to add these libs to build a SDL/GL app ?

cheers

Harry
It all depends on what the game links to / requires. Im pretty sure a lot of the newer kernel games require these libs installed.

Wally
Post Reply