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 

C++ ends up in undefined references

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



Joined: 20 Feb 2009
Posts: 19

PostPosted: Fri May 22, 2009 12:22 am    Post subject: C++ ends up in undefined references Reply with quote

Hey,
well, I want to use Object Oriented Programming so I took my program (that compiles just great in C), changed it to .cpp, added my classes, added -lstdc++ to the makefile and what happened? I can't compile anymore! It gives me undefined references when linking I think. See the errors:

Code:

1>C:/pspsdk/bin/rm -f mouseconf.elf  framebuffer.o graphics.o sioDriver.o main.o pgeFont.o PARAM.SFO EBOOT.PBP EBOOT.PBP
1>psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150   -c -o framebuffer.o framebuffer.c
1>psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150   -c -o graphics.o graphics.c
1>psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall   -c -o sioDriver.o sioDriver.S
1>psp-g++ -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150   -c -o main.o main.cpp
1>psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150   -c -o pgeFont.o pgeFont.c
1>psp-gcc -I. -IC:/pspsdk/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150  -L. -LC:/pspsdk/psp/sdk/lib   framebuffer.o graphics.o sioDriver.o main.o pgeFont.o -lpspgum -lpspgu -lpng -lz -lm -lfreetype -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o mouseconf.elf
1>main.o: In function `get_input_thread(unsigned int, void*)':
1>main.cpp:(.text+0x168): undefined reference to `sioPutchar(int)'
1>main.cpp:(.text+0x18c): undefined reference to `sioReadChar()'
1>main.cpp:(.text+0x1a4): undefined reference to `sioReadChar()'
1>main.cpp:(.text+0x204): undefined reference to `sioReadChar()'
1>main.cpp:(.text+0x214): undefined reference to `sioReadChar()'
1>main.cpp:(.text+0x28c): undefined reference to `resetFBuf()'
1>main.o: In function `initSerialPort()':
1>main.cpp:(.text+0x430): undefined reference to `sioInit(int)'
1>main.o: In function `main':
1>main.cpp:(.text+0x600): undefined reference to `loadImage(char const*)'
1>main.cpp:(.text+0x614): undefined reference to `loadImage(char const*)'
1>main.cpp:(.text+0x628): undefined reference to `loadImage(char const*)'
1>main.cpp:(.text+0x638): undefined reference to `loadImage(char const*)'
1>main.cpp:(.text+0x648): undefined reference to `loadImage(char const*)'
1>main.o:main.cpp:(.text+0x658): more undefined references to `loadImage(char const*)' follow
1>main.o: In function `main':
1>main.cpp:(.text+0x69c): undefined reference to `initGraphics()'
1>main.cpp:(.text+0x6b0): undefined reference to `clearScreen(unsigned int)'
1>main.cpp:(.text+0x6d0): undefined reference to `blitAlphaImageToScreen(int, int, int, int, Image*, int, int)'
1>main.cpp:(.text+0x6d8): undefined reference to `FadeScreen(int)'
1>main.cpp:(.text+0x6f4): undefined reference to `flipScreen()'
1>main.cpp:(.text+0x710): undefined reference to `flipScreen()'
1>main.cpp:(.text+0x784): undefined reference to `clearScreen(unsigned int)'
1>main.cpp:(.text+0x7a8): undefined reference to `blitAlphaImageToScreen(int, int, int, int, Image*, int, int)'
1>main.cpp:(.text+0x808): undefined reference to `blitAlphaImageToScreen(int, int, int, int, Image*, int, int)'
1>main.cpp:(.text+0x810): undefined reference to `guStart()'
1>main.cpp:(.text+0x97c): undefined reference to `blitAlphaImageToScreen(int, int, int, int, Image*, int, int)'
1>main.cpp:(.text+0x98c): undefined reference to `flipScreen()'
1>main.cpp:(.text+0x99c): undefined reference to `FadeScreen(int)'
1>main.cpp:(.text+0x9b0): undefined reference to `flipScreen()'
1>main.cpp:(.text+0x9d8): undefined reference to `blitAlphaImageToScreen(int, int, int, int, Image*, int, int)'
1>main.cpp:(.text+0xa00): undefined reference to `blitAlphaImageToScreen(int, int, int, int, Image*, int, int)'


makefile:
Code:
TARGET = mouseconf
OBJS = framebuffer.o graphics.o sioDriver.o main.o pgeFont.o

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

LIBS = -lpspgum -lpspgu -lpng -lz -lm -lfreetype


EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Mouse Config

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



as you can see there are only errors in the stub and the graphics thing, pgeFont doesn't drop any error
pls help
TD
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Fri May 22, 2009 12:37 am    Post subject: Reply with quote

All the libraries you are trying to call are written in C.
So normally the externs for those functions in the .h file would be surrounded by

#ifdef __cplusplus
extern "C" {
#endif
...most of the contents of your .h file
#ifdef __cplusplus
}
#endif

It looks like the headers you're using don't do this, so you're getting a compile problem.

Btw, C and C++ are quite different, and you shouldn't necessarily expect your C code to compile as C++.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Fri May 22, 2009 12:38 am    Post subject: Reply with quote

some c specific options require extern "C" {//code here}

edit: son of a b***h well mine is shorter and says the same thing
Back to top
View user's profile Send private message MSN Messenger
TokyoDriftPSP



Joined: 20 Feb 2009
Posts: 19

PostPosted: Fri May 22, 2009 12:50 am    Post subject: Reply with quote

well the ifdef __cpluplus extern "C" stuff is in the graphics.h and the pgeFont.h, not in the sioDriver.s - this one is being assembled anyway...
but the errors are there when linking, not before, so i think this can't be caused by a mistake in the sources, can it?
TD
Back to top
View user's profile Send private message
TokyoDriftPSP



Joined: 20 Feb 2009
Posts: 19

PostPosted: Fri May 22, 2009 3:26 am    Post subject: Reply with quote

okay i made
extern "C"{
*includes*
*callbacks*
}
in main.cpp and it works now
TD
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