Problems with sdl and c++
-
- Posts: 43
- Joined: Mon Sep 10, 2007 9:32 am
Problems with sdl and c++
Hello actually i'm developing a game for psp in c++ and SDL. In order to speed up the debuging i maked all the game engine in the pc using only sdl standards and C++ STD.
But now i want to try the code in the psp in order to make a checkpoint. But i tried a easy hello word in psp sdl c++ but it doesnt work it says something like:
SDL_main not defined
at linking. But compiling a game with sdl and c ( not C++) it works pretty good.
What do you think i can do to solve the problem?
But now i want to try the code in the psp in order to make a checkpoint. But i tried a easy hello word in psp sdl c++ but it doesnt work it says something like:
SDL_main not defined
at linking. But compiling a game with sdl and c ( not C++) it works pretty good.
What do you think i can do to solve the problem?
-
- Posts: 43
- Joined: Mon Sep 10, 2007 9:32 am
As i've said i have already make a c game using sdl ( yes an entire game!) so... yes it is installed.
but the problem only appears when i'm using c++
also if someone has tried sdl on c++ using pspsdk and sdl libraries and can lend me a hand attaching a sample code Something like a hello world and a makefile.
the compiling order is:
notice that it links using gcc so i think there is a problem too thats why i tried using the same order but using psp-g++ to avoid the operator new[](unsigned int)' not defined error.
the entire error log is:
EDIT:--------------------------------------------------------------------------------------------------
in order to compile i've tried this commands:
it now compiles without errors but the game doesn't run on psp so i'm thinking that it should be problem that the main is not defined in the elf the app doesn't know where to start. could it be??
but the problem only appears when i'm using c++
also if someone has tried sdl on c++ using pspsdk and sdl libraries and can lend me a hand attaching a sample code Something like a hello world and a makefile.
the compiling order is:
Code: Select all
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wno-long-long -G0 -O2 -DJOY_YES -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main -c -o test1.o test1.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wno-long-long -G0 -O2 -DJOY_YES -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main -c -o csprite.o csprite.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wno-long-long -G0 -O2 -DJOY_YES -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/lib test1.o csprite.o -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o testi.elf
the entire error log is:
Code: Select all
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): En la función `sdl_psp_exit_callback':
psp/SDL_psp_main.c:54: definiciones múltiples de `sce_newlib_attribute'
test1.o:(.data+0x0): primero se definió aquí
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): En la función `sdl_psp_exit_callback':
psp/SDL_psp_main.c:54: definiciones múltiples de `module_info'
test1.o:(.rodata.sceModuleInfo+0x0): primero se definió aquí
test1.o:(.eh_frame+0x11): referencia a `__gxx_personality_v0' sin definir
csprite.o: En la función `CSprite::CSprite(int)':
csprite.cpp:(.text+0x9c): referencia a `operator new[](unsigned int)' sin definir
csprite.o: En la función `CSprite::CSprite(int)':
csprite.cpp:(.text+0xdc): referencia a `operator new[](unsigned int)' sin definir
csprite.o: En la función `CSprite::CSprite()':
csprite.cpp:(.text+0x114): referencia a `operator new[](unsigned int)' sin definir
csprite.o: En la función `CSprite::CSprite()':
csprite.cpp:(.text+0x14c): referencia a `operator new[](unsigned int)' sin definir
csprite.o:(.eh_frame+0x11): referencia a `__gxx_personality_v0' sin definir
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): En la función `main':
psp/SDL_psp_main.c:(.text+0x358): referencia a `SDL_main' sin definir
collect2: ld devolvi'o el estado de salida 1
make: *** [testi.elf] Error 1
EDIT:--------------------------------------------------------------------------------------------------
in order to compile i've tried this commands:
Code: Select all
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wno-long-long -G0 -O2 -DJOY_YES -I/usr/local/pspdev/psp/include/SDL -c -o test1.o test1.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wno-long-long -G0 -O2 -DJOY_YES -I/usr/local/pspdev/psp/include/SDL -c -o csprite.o csprite.cpp
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -Wall -Wno-long-long -G0 -O2 -DJOY_YES -I/usr/local/pspdev/psp/include/SDL -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/lib test1.o csprite.o -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o testi.elf
Last edited by saulotmalo2 on Mon Sep 10, 2007 10:54 am, edited 1 time in total.
-
- Posts: 26
- Joined: Sat Jun 02, 2007 1:15 am
-
- Posts: 43
- Joined: Mon Sep 10, 2007 9:32 am
its ok, all the helps are welcome. Also i'm not new ... but i've forgot the password xD. And i have develop some psp apps. But now it is turning me mad.
your project uses C++ & sdl? can i have your makefile or your... source? i mean only a litle hello world would be perfect.
EDIT: as you can see on the post before i'm linking the main and the sdl but i'm not sure about what -Dmain is doing so i've erased it but... now it compiles but don't run :(
your project uses C++ & sdl? can i have your makefile or your... source? i mean only a litle hello world would be perfect.
EDIT: as you can see on the post before i'm linking the main and the sdl but i'm not sure about what -Dmain is doing so i've erased it but... now it compiles but don't run :(
-
- Posts: 26
- Joined: Sat Jun 02, 2007 1:15 am
Here is my Makefile
and a bit of my Main.cpp
I understand it's a quick example.. Let me know if you anything else
Cheers
Code: Select all
TARGET = Test
OBJS = main.o $(PSP_OBJS)
INCDIR =
CFLAGS = -G4 -Wall -O3 -I/usr/local/pspdev/psp/include/SDL
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
LIBDIR =
LDFLAGS =
STDLIBS= -lSDLmain -lSDL_image -lSDL_ttf -lfreetype -lSDL -lpng -ljpeg -lm -lz -lstdc++ \
-lpspsdk -lpspctrl -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lpsphprm \
-lSDL_mixer -lpsphprm
LIBS=$(STDLIBS)$(YOURLIBS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test
PSPSDK=$(shell psp-config --pspsdk-path)
DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
include $(PSPSDK)/lib/build.mak
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <psppower.h>
#include <psprtc.h>
#include <png.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string>
#include <list>
#include <iostream>
#include <fstream>
#include "alarm.h"
#include "alarmmanager.h"
#include "button.h"
using namespace std;
PSP_MODULE_INFO("Test", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
static bool isrunning = true;
static int curWindow = 1;
// Exit callback
int exit_callback(int arg1, int arg2, void *common) {
isrunning = false;
sceKernelExitGame();
return 0;
}
// Callback thread
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
// Sets up the callback thread and returns its thread id
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main() {
//Initialize the controler and the PSP Speed
SceCtrlData pad;
scePowerSetClockFrequency(166, 166, 166);
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
//Initialize the SDL Library (audio and video)
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
cout << stderr << "Couldn't initialize SDL: " << SDL_GetError() << endl;
//Initialize the SDL True Type Font Library
if(TTF_Init() < 0)
cout << stderr << "Couldn't initialize TTF: " << SDL_GetError() << endl;
//Initialize the font color.
SDL_Color white = {255, 255, 255};
SDL_Color black = {0, 0, 0};
//Initializing the images and text.
/*SDL_Rect txtcalendar_position;
txtcalendar_position.x = 130;
txtcalendar_position.y = 146;*/
//Chargement des images.
SDL_Surface *background;
SDL_Surface *ecran = SDL_SetVideoMode(480, 272, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
background = SDL_DisplayFormat(IMG_Load("data/gfx/blackbackground.png"));
//iconCalendar = SDL_DisplayFormatAlpha(IMG_Load("data/gfx/calendar.png"));
//Initialisation du mode Debug de la PSP
pspDebugScreenInit();
SetupCallbacks();
//Start the loop
while(isrunning)
{
sceCtrlReadBufferPositive(&pad, 1);
sceRtcGetCurrentClockLocalTime(&time);
SDL_BlitSurface(background, NULL, ecran, &background_position);
SDL_BlitSurface(mousePointer, NULL, ecran, &mouse);
SDL_Flip(ecran);
}
//Free the memory.
SDL_FreeSurface(background);
SDL_Quit();
sceKernelSleepThread();
return 0;
}
Cheers
-
- Posts: 43
- Joined: Mon Sep 10, 2007 9:32 am
when i compile your code i get this errors:
i tried to clean a little but i don't know where is the problem :(
EDIT-----------------------------------------------------------------------------------------
can you put the code that the makefile tries to compile? because a leak some libraries that you have.
only put on the shell :
make > log.txt
and send the log.txt.
thaks i think i'm getting the error
Code: Select all
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(eglCreateContext.o): En la función `eglCreateContext':
/cygdrive/c/pspgl2/eglCreateContext.c:43: referencia a `pspvfpu_initcontext' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(eglDestroyContext.o): En la función `eglDestroyContext':
/cygdrive/c/pspgl2/eglDestroyContext.c:42: referencia a `pspvfpu_deletecontext' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(glLoadIdentity.o): En la función `glLoadIdentity':
/cygdrive/c/pspgl2/glLoadIdentity.c:23: referencia a `pspvfpu_use_matrices' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(pspgl_context.o): En la función `flush_matrix':
/cygdrive/c/pspgl2/pspgl_context.c:107: referencia a `pspvfpu_use_matrices' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(pspgl_matrix.o): En la función `__pspgl_matrix_sync':
/cygdrive/c/pspgl2/pspgl_matrix.c:19: referencia a `pspvfpu_use_matrices' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(pspgl_matrix.o): En la función `__pspgl_matrix_load':
/cygdrive/c/pspgl2/pspgl_matrix.c:33: referencia a `pspvfpu_use_matrices' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libgl.a(glMultMatrixf.o): En la función `glMultMatrixf':
/cygdrive/c/pspgl2/glMultMatrixf.c:17: referencia a `pspvfpu_use_matrices' sin definir
collect2: ld devolvi'o el estado de salida 1
make: *** [Test.elf] Error 1
EDIT-----------------------------------------------------------------------------------------
can you put the code that the makefile tries to compile? because a leak some libraries that you have.
only put on the shell :
make > log.txt
and send the log.txt.
thaks i think i'm getting the error
Check out this thread:
http://forums.qj.net/f-psp-development- ... 39653.html
I was having the same problem, but lostjared's fix solved it!
http://forums.qj.net/f-psp-development- ... 39653.html
I was having the same problem, but lostjared's fix solved it!
-
- Posts: 43
- Joined: Mon Sep 10, 2007 9:32 am
i have compiled using AllSystemGo schema now it works ( at least i can compile c++ sdl on psp) but i like to use sdlmain standard, that means that i don't have to redefine the callbacks.
how can i do it?
EDIT--------------------------------------------------------------------------------
i've tried use extern but then when i trie to execute the game frezes. ( even does not start)
how can i do it?
EDIT--------------------------------------------------------------------------------
i've tried use extern but then when i trie to execute the game frezes. ( even does not start)
-
- Posts: 43
- Joined: Mon Sep 10, 2007 9:32 am