| View previous topic :: View next topic |
| Author |
Message |
lantus

Joined: 10 May 2005 Posts: 10
|
Posted: Mon May 23, 2005 12:11 pm Post subject: working C++ samples? |
|
|
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 |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Mon May 23, 2005 12:35 pm Post subject: |
|
|
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 |
|
 |
t3ddY
Joined: 08 May 2005 Posts: 12 Location: The Netherlands
|
Posted: Tue May 24, 2005 3:27 am Post subject: |
|
|
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 |
|
 |
Treat
Joined: 26 Sep 2004 Posts: 16
|
Posted: Wed May 25, 2005 10:33 pm Post subject: |
|
|
| it works just fine on hardware |
|
| Back to top |
|
 |
lantus

Joined: 10 May 2005 Posts: 10
|
Posted: Thu May 26, 2005 4:52 pm Post subject: |
|
|
excellent thanks for checking it out Treat _________________ xSnes9x - Snes9x Emulation for Xbox Consoles |
|
| Back to top |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Thu May 26, 2005 11:42 pm Post subject: |
|
|
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 |
|
 |
cwbowron

Joined: 06 May 2005 Posts: 76 Location: East Lansing, MI
|
Posted: Fri May 27, 2005 12:37 am Post subject: |
|
|
| 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 |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Fri May 27, 2005 12:46 am Post subject: |
|
|
| my bad. thx for the clarification. |
|
| Back to top |
|
 |
t3ddY
Joined: 08 May 2005 Posts: 12 Location: The Netherlands
|
Posted: Fri May 27, 2005 10:47 pm Post subject: |
|
|
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 |
|
 |
Zeta
Joined: 09 Jul 2005 Posts: 9
|
Posted: Sat Jul 09, 2005 1:53 pm Post subject: |
|
|
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 |
|
 |
|