windows SDL to PSP, SDL_main undefined reference

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

Moderators: cheriff, TyRaNiD

Post Reply
jo3_sum
Posts: 17
Joined: Wed Jan 30, 2008 5:38 am
Contact:

windows SDL to PSP, SDL_main undefined reference

Post by jo3_sum »

Hi, I have an error when trying to port my SDL windows game to the psp.
I searched on google, but I can't seem to get it working.

Error:

Code: Select all

C:\SDLdev\projects\game>make -f makefile.psp
process_begin: CreateProcess((null), C:/pspdev/psp/sdk/../bin/sdl-config --cflag
s, ...) failed.
process_begin: CreateProcess((null), C:/pspdev/psp/sdk/../bin/sdl-config --cflag
s, ...) failed.
process_begin: CreateProcess((null), C:/pspdev/psp/sdk/../bin/sdl-config --libs,
 ...) failed.
psp-gcc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -g -Wall -I C:\pspdev\psp\includ
e\freetype2 -L C:\pspdev\psp\lib -DPSP  -D_PSP_FW_VERSION=401  -L. -LC:/pspdev/p
sp/sdk/lib -specs=C:/pspdev/psp/sdk/lib/prxspecs -Wl,-q,-TC:/pspdev/psp/sdk/lib/
linkfile.prx   C:/pspdev/psp/sdk/lib/prxexports.o -lstdc++ -lc -lSDLmain -lSDL
-lSDL_image -lSDL_ttf -lSDL_mixer -lfreetype -lpng -lz -lm -ljpeg -lpspaudio -lp
sphprm -lpspgu -lpspwlan -lpsppower -lpsprtc   -lpspdebug -lpspdisplay -lpspge -
lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -l
psputility -lpspuser -lpspkernel -o game.elf
C:\pspdev\psp\lib\libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:178: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
make: *** [game.elf] Error 1

Makefile:

Code: Select all


TARGET = Game

SRC =	main.cpp globalclasses.cpp games.cpp menu.cpp scenes.cpp

OBJ = $(addsuffix .o, $(basename $(SRC)))


INCDIR = 
CFLAGS = -O2 -G0 -g -Wall -I C:\pspdev\psp\include\freetype2 -L C:\pspdev\psp\lib -DPSP
PSP_FW_VERSION=401
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS) -c
PSP_VERSION_FW= 401
LIBDIR =
LDFLAGS =
LIBS = -lstdc++ -lc -lSDLmain -lSDL  -lSDL_image -lSDL_ttf -lSDL_mixer -lfreetype -lpng -lz -lm -ljpeg -lpspaudio -lpsphprm -lpspgu -lpspwlan -lpsppower -lpsprtc 

PSP_EBOOT_ICON = NULL
PSP_EBOOT_PIC1 = NULL

BUILD_PRX=1
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Game

PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
CXXFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
include $(PSPSDK)/lib/build.mak


Can someone who knows what to do help me, please.
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

you're looking for sdl-config in the wrong place
if its not in C:/pspdev/psp/bin
then it should be in C:/pspdev/bin

The first time i used sdl i did $(shell $(PSPBIN)/sdl-config --cflags) as well and got the same error
I just changed it to $(shell sdl-config --cflags) and it worked.
I don't know if it will work for both /bin and /psp/bin though.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

psPea wrote:you're looking for sdl-config in the wrong place
if its not in C:/pspdev/psp/bin
then it should be in C:/pspdev/bin

The first time i used sdl i did $(shell $(PSPBIN)/sdl-config --cflags) as well and got the same error
I just changed it to $(shell sdl-config --cflags) and it worked.
I don't know if it will work for both /bin and /psp/bin though.
Using "$(shell sdl-config --cflags)" runs the system's sdl-config, not the PSP toolchain's sdl-config. You have to put the path in there, and the way he was doing it was correct. Most SDL stuff on the PSP does it just like that. From the failure messages he posted, it's like sdl-config is not installed in the toolchain. He needs to be sure it's there or get rid of it by changing the makefile to have what "$(shell sdl-config --cflags)" would have returned.
jo3_sum
Posts: 17
Joined: Wed Jan 30, 2008 5:38 am
Contact:

Post by jo3_sum »

I change it to this:

Code: Select all

PSPBIN = $(PSPSDK)/../../bin
the top three errors went away, but I still have the undefined reference error
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

you might have to put an
extern "C"
before your main
Last edited by psPea on Sat Jan 03, 2009 1:24 pm, edited 1 time in total.
jo3_sum
Posts: 17
Joined: Wed Jan 30, 2008 5:38 am
Contact:

Post by jo3_sum »

I'm using c++
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

exactly
jo3_sum
Posts: 17
Joined: Wed Jan 30, 2008 5:38 am
Contact:

Post by jo3_sum »

Oh, I was thinking it was used the other way for some reason. I'm testing now. I'll update this post to tell you my results.
EDIT:
It compiled. I used HardHat's pspflashcards src as a model. So a thanks to him.
Post Reply