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++ R_MIPS_GPREL16 against _impure_ptr

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



Joined: 01 Jul 2005
Posts: 197

PostPosted: Sun Oct 09, 2005 6:52 pm    Post subject: C++ R_MIPS_GPREL16 against _impure_ptr Reply with quote

I'm in the middle of porting some C++ heavy code, and I think that it's pretty close to finished, as all the cpp files can be compiled into .o files, but when I come to link them all I get this error:
Code:
/psp/lib/libstdc++.a(pure.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:69: undefined reference to '_impure_ptr'
and this notice:
Code:
/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:69:relocation truncated to fit: R_MIPS_GPREL16 against '_impure_ptr'

Now although I've programmed in C++ before, I havent used g++ before, so I don't really know where to go from here.
Any help appreciated.
Back to top
View user's profile Send private message
sherpya



Joined: 03 Oct 2005
Posts: 61

PostPosted: Mon Oct 10, 2005 1:12 am    Post subject: Reply with quote

add -G0 to CXXFLAGS (or CPPFLAGS) hmm or perhaps to link flags since is a problem when linking stdc++ it's seams that libstdc++ is not compiled with -G0
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Mon Oct 10, 2005 1:32 am    Post subject: Reply with quote

I'd already added -G0, but looking at the makefile, I had made a foolish mistake, I'd kept USE_PSPSDK_LIBC = 1 in....
*hits himself with heavy object*
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Mon Oct 10, 2005 2:30 am    Post subject: Reply with quote

Yes, the recent changes to psplibc make linking to libstdc++ impossible. libstdc++ is built against the newlib headers, which define _impure_ptr. So you have to link against newlib if you want to link against libstdc++.

As far as -G0 goes, it's no longer required for your own source. If you try using -G8 (or just leave -G0 out) and get any linker errors you should bring them up.

In short, do not use psplibc when building a C++ program.
Back to top
View user's profile Send private message
sherpya



Joined: 03 Oct 2005
Posts: 61

PostPosted: Mon Oct 10, 2005 8:50 pm    Post subject: Reply with quote

I've managed to link some c++ stuff, buy using gcc instead of g++ and adding -lstdc++, anyway there are some issues with the linker, since linked library are not position indipendant in the command line and sometimes getting the correct sequence is a nightmare
Back to top
View user's profile Send private message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Tue Oct 11, 2005 1:49 am    Post subject: Reply with quote

Well, for those interested, I've got away from the linker problems by removing PSPSDK_LIBC, and now i'm back to project-related errors, which are very numerous, but hopefully solveable.
If I come up with any more linker problems, i'll post them here.
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