c++ with on psp?

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

Moderators: cheriff, TyRaNiD

Post Reply
dospro
Posts: 13
Joined: Thu Sep 14, 2006 11:17 am

c++ with on psp?

Post by dospro »

Hi. it's me again.
well, i have coded a little application in C++, but it doesn't want to link.
It seems to be compiling quite well but at the time of the linking, it gives me lot of undefined references.
As far as i know i am linking with SDL correctly(i suppose).
The linking errors are known to me. They appear when no libstdc++ is detected. sometihn like:

"undefined reference for operator new"(sorry, it appears in spanish).

This is the makefile i am using.
TARGET = biogb

SRCDIR = src
SOURCES = ${SRCDIR}/main.cpp \
${SRCDIR}/cGfx.cpp \
${SRCDIR}/cInput.cpp \
${SRCDIR}/cLibGfx.cpp \
${SRCDIR}/cNet.cpp \
${SRCDIR}/cSound.cpp \
${SRCDIR}/cCpu.cpp \

OBJS = ${SOURCES:.c=.o}

CFLAGS = -DLINUX -DUSE_SDL -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE =pspBioGB

PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
include $(PSPSDK)/lib/build.mak
I hope someone can help me. Thanks
IronAvatar
Posts: 23
Joined: Sat Nov 25, 2006 5:53 am

Post by IronAvatar »

Have you tried adding the following line before including the sdk make file?

Code: Select all

USE_PSPSDK_LIBC=1
Or is it reccomended that you use the new libc with the sdl port? It could also be a link order problem which can be a bit of a pain to sort out.
dospro
Posts: 13
Joined: Thu Sep 14, 2006 11:17 am

Post by dospro »

Well, the SDL readme says that i should put like that.
but maybe you are right, it may be a linking order problem.
Which i solve how??? Editing the build.mak?
IronAvatar
Posts: 23
Joined: Sat Nov 25, 2006 5:53 am

Post by IronAvatar »

Have you tried using the sdk libc? And if so, do you still get the link errors?

If you still get this error, then yes, the only real way to change the link order is to edit the build.mak file. It doesn't have to be a big change though.

I would create a new variable called something like LIB_ALTERNATE and then in the build.mak file, do something like this;

Code: Select all

ifeq ($(LIB_ALTERNATE),)
### Existing script for setting the LIB variable in build.mak
else
    LIBS = $(LIB_ALTERNATE)
endif
Then in your makefile, set the LIB_ALTERNATE variable to use the sdk and sdl libs that you need, and then you can mess around with the link order.

Hope this helps, fixing link order issues is a real pain in the backside :(
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Huh?
No, just add -lstdc++ -lc to your LIBS line.
Also, search the forums, compiling C++ code has been discussed to death already.
dospro
Posts: 13
Joined: Thu Sep 14, 2006 11:17 am

Post by dospro »

Well. that did it. Although there were more errors found about unreferenced SDL_main.
I will have to search about this error.
Thanks for the help
seventh
Posts: 11
Joined: Sat Jan 21, 2006 2:10 am

Re: c++ with on psp?

Post by seventh »

dospro wrote:

Code: Select all

OBJS    = ${SOURCES:.c=.o}
Shouldn't that be

Code: Select all

OBJS    = ${SOURCES:.cpp=.o}
?
dospro
Posts: 13
Joined: Thu Sep 14, 2006 11:17 am

Post by dospro »

I thought so, but i don't know how nor why it wroks this way.
So i just left it as it was.
Post Reply