forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"New" operator is undefined

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
JustChris



Joined: 03 Nov 2005
Posts: 21

PostPosted: Tue Jan 17, 2006 9:37 am    Post subject: "New" operator is undefined Reply with quote

I can't seem to use much of STL because most of them use the 'new' and 'delete' operators. In fact, just dynamically allocating objects gives me the error.

Code:
int *ptr;
ptr = new int[10];

// error returned
main.cpp:(.text+0x5a30): Undefined reference to 'operator new[](unsigned int)'



Is there something that I forgot to link against? Here is the makefile used.

Code:

TARGET = Test
OBJS = main.o sprite.o psp-setup.o sprite-rgba.o map1-rgba.o sprite-mono.o

INCDIR =
CFLAGS = -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
LIBS = -lglut -lGL -lm -lpsprtc

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Testing
PSP_EBOOT_ICON = test.png

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

AS=psp-as

psp-setup.o: psp-setup.c Makefile
psp-setup.o: CFLAGS += -DMODULE_NAME="$(TARGET)"

sprite.o: sprite.cpp sprite.h
main.o: main.cpp sprite.h

%.o: %.raw
   (sym=`echo $* | tr '-' '_'`; \
    echo -e ".data\n.global $${sym}_start\n$${sym}_start:\n\t.incbin \"$<\"" | $(AS) -o $@)

%-rgba.raw: %-rgba.png
   convert $< rgba:$@

%-mono.raw: %-mono.png
   convert $< gray:$@

%-sys.o: %.c
   gcc -g -Wall -DSYS -c -o $@ $<

sys: test-sys.o sprite-sys.o sprite-mono.o sprite-rgba.o
   gcc -o sys $^ -lglut


EDIT: NVM, it got fixed! I didn't add -lstdc++ to LIBS.
Back to top
View user's profile Send private message
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Wed Jan 18, 2006 2:39 am    Post subject: Reply with quote

Link with stdc++

-lstdc++ to your LIBS variable in your makefile. That should do it.
_________________
Br, Sandberg
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group