C++ R_MIPS_GPREL16 against _impure_ptr

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

Moderators: cheriff, TyRaNiD

Post Reply
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

C++ R_MIPS_GPREL16 against _impure_ptr

Post by AnonymousTipster »

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: Select all

/psp/lib/libstdc++.a(pure.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:69: undefined reference to '_impure_ptr'
and this notice:

Code: Select all

/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.
User avatar
sherpya
Posts: 61
Joined: Mon Oct 03, 2005 5:49 pm

Post by sherpya »

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
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

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*
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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.
User avatar
sherpya
Posts: 61
Joined: Mon Oct 03, 2005 5:49 pm

Post by sherpya »

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
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

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.
Post Reply