When I try to compile this main.cpp:
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sdl.h>
#include <sdl_image.h>
//PSP_MODULE_INFO("CONTROLTEST", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
void dump_threadstatus(void);
int done = 0;
int exit_callback(int arg1, int arg2, void *common)
{
done = 1;
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
void DrawImage( SDL_Surface * src_surface, int x, int y, SDL_Surface * dest_surface )
{
// Here, we construct a rectangle representing the entire image.
SDL_Rect src_rect ;
src_rect.x = 0 ;
src_rect.y = 0 ;
src_rect.w = src_surface->w ;
src_rect.h = src_surface->h ;
// We construct a rectangle representing where we want the
// image to be located on the destination surface.
SDL_Rect dest_rect ;
dest_rect.x = x ;
dest_rect.y = y ;
// This is where all the magic happens. The source surface
// is mapped onto the destination surface.
SDL_BlitSurface( src_surface, &src_rect, dest_surface, &dest_rect ) ;
}
int main(void)
{
SceCtrlData pad;
pspDebugScreenInit();
SetupCallbacks();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
SDL_Surface *screen, *img;
screen = SDL_SetVideoMode(480, 272, 16, SDL_DOUBLEBUF | SDL_FULLSCREEN);
img = IMG_Load("test.png");
SDL_FillRect(screen,NULL, 0x000000); //Clear screen
DrawImage(img, 0, 0, screen);
SDL_Flip(screen);
while(!done)
{
pspDebugScreenSetXY(0, 2);
sceCtrlReadBufferPositive(&pad, 1);
}
SDL_FreeSurface(img);
sceKernelExitGame();
return 0;
}
I get this error:
Code: Select all
C:\pspsdk\psp\christer\New>make
psp-g++ -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D PSP -IC:/pspsdk/psp/inc
lude/SDL -Dmain=SDL_main -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D PSP -
IC:/pspsdk/psp/include/SDL -Dmain=SDL_main -fno-exceptions -fno-rtti -D_PSP_FW_
VERSION=150 -c -o main.o main.cpp
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D PSP -IC:/pspsdk/psp/inc
lude/SDL -Dmain=SDL_main -D_PSP_FW_VERSION=150 -L. -LC:/pspsdk/psp/sdk/lib m
ain.o -lstdc++ -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng -lz -lm -lSDL_mixer
-lvorbisidec -lmikmod -lmad -LC:/pspsdk/psp/lib -lSDLmain -lSDL -lm -lGL -lpspv
fpu -LC:/pspsdk/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -l
psphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lps
pnet_inet -lpspaudiolib -lpspaudio -lpsppower -lpspdebug -lpspdisplay -lpspge -
lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -l
psputility -lpspuser -lpspkernel -o main.elf
C:/pspsdk/psp/lib\libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:86: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
make: *** [main.elf] Error 1
Using this makefile:
Code: Select all
TARGET = main
OBJS = main.o
PSPSDK = $(shell psp-config --pspsdk-path)
PSPDEV = $(shell psp-config -d)
PSPBIN = $(PSPDEV)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
CFLAGS = -O2 -G0 -Wall -D PSP
CFLAGS += $(shell $(SDL_CONFIG) --cflags)
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBS = -lstdc++ -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng -lz -lm -lSDL_mixer -lvorbisidec -lmikmod -lmad $(shell $(SDL_CONFIG) --libs)
LIBS += -lpspaudiolib -lpspaudio -lpsppower
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Ohaspii
include $(PSPSDK)/lib/build.mak
I don't get any errors if I name it main.c.