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 

working C++ samples?

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



Joined: 10 May 2005
Posts: 10

PostPosted: Mon May 23, 2005 12:11 pm    Post subject: working C++ samples? Reply with quote

has anyone managed to build a C++ project?

by that i mean as an example take nem's hello world source, rename *.c to *.cpp and link to libSTDC++. I've tried everything and cant get it to link correctly.

anyone have a solution?
_________________
xSnes9x - Snes9x Emulation for Xbox Consoles
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Mon May 23, 2005 12:35 pm    Post subject: Reply with quote

The short answer is that you can't use libstdc++ on the PSP because in the toolchain nem uses libstdc++ was built for the PS2's EE which has a different executable and instruction format than the PSP. See this thread for details: http://forums.ps2dev.org/viewtopic.php?p=11410#11410

The solution is to roll your own GCC toolchain targetted specifically for the PSP's R4K CPU, or wait for someone else to do it.
Back to top
View user's profile Send private message
t3ddY



Joined: 08 May 2005
Posts: 12
Location: The Netherlands

PostPosted: Tue May 24, 2005 3:27 am    Post subject: Reply with quote

I managed to get ee-g++ working and make a elf. But the thing was, it didn't run on PSPE and since i don't have a 1.0 jap psp, i couldn't try it myself...

But it's very simple, take the hello world example en compile it with ee-g++... put the xmain in a extern "C" { } if it can't find it and add -fno-exceptions to ee-ld...

Maybe it will run on actual hardware, can't test it from here :(
Back to top
View user's profile Send private message MSN Messenger
Treat



Joined: 26 Sep 2004
Posts: 16

PostPosted: Wed May 25, 2005 10:33 pm    Post subject: Reply with quote

it works just fine on hardware
Back to top
View user's profile Send private message
lantus



Joined: 10 May 2005
Posts: 10

PostPosted: Thu May 26, 2005 4:52 pm    Post subject: Reply with quote

excellent thanks for checking it out Treat
_________________
xSnes9x - Snes9x Emulation for Xbox Consoles
Back to top
View user's profile Send private message
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Thu May 26, 2005 11:42 pm    Post subject: Reply with quote

what exactly is the point in compiling the code as C code with g++? (that's what extern "C" does?)

Last edited by weak on Fri May 27, 2005 12:46 am; edited 1 time in total
Back to top
View user's profile Send private message
cwbowron



Joined: 06 May 2005
Posts: 76
Location: East Lansing, MI

PostPosted: Fri May 27, 2005 12:37 am    Post subject: Reply with quote

weak wrote:
what exactly is the point in compiling the code as C code with g++? (that's what extern "C" does)


extern "C" tells the compiler not to mangle the name so that it can be exported correctly to the linker. It does not force it to compile as C code.

C++ compilers usually mangle the function name by including information about its arguments and such in the exported symbol.
Back to top
View user's profile Send private message Visit poster's website
weak



Joined: 13 Jan 2005
Posts: 114
Location: Vienna, Austria

PostPosted: Fri May 27, 2005 12:46 am    Post subject: Reply with quote

my bad. thx for the clarification.
Back to top
View user's profile Send private message
t3ddY



Joined: 08 May 2005
Posts: 12
Location: The Netherlands

PostPosted: Fri May 27, 2005 10:47 pm    Post subject: Reply with quote

If you want to check the output, just check the helloworld.map in the mk.bat script... you will see that c++ functionnames will be named differently then c functionnames...

With extern "C" you prevent this.
Back to top
View user's profile Send private message MSN Messenger
Zeta



Joined: 09 Jul 2005
Posts: 9

PostPosted: Sat Jul 09, 2005 1:53 pm    Post subject: Reply with quote

I've been taking a look at the samples from the sdk in svn and in one of my tests I wanted to compile some samples in c++ (it should be just changing the extension to cpp right?). The result was that some projects compiled and linked ok but others (specially when using the psppower lib) wouldn't link but compiled fine. The thing is that it couldn't resolve functions like scePowerIsBatteryExist, scePowerRegisterCallback, etc...
Can somebody tell me what can be happening here? Is it possible that when switching to c++ the declaration of the function is different than the code on the library?
Thank you very much in advance.
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