[Question]Can we use CPP in PSP programming progress?
-
- Posts: 6
- Joined: Fri Jul 14, 2006 8:56 pm
[Question]Can we use CPP in PSP programming progress?
I have found that almost all the PSPSDK samples was wrote by C, not CPP. Can we develop homebrew application by using CPP for PSP?
-
- Posts: 9
- Joined: Tue Jul 18, 2006 3:29 pm
I had the same trouble trying to use the "graphics.c" and "graphics.h" (from the six main PSP dev tutorials) as C++ files for my main.cpp, even after I changed graphics.c to graphics.cpp. I kept getting weird linker errors so I gave up and started learning some C. It's about the same, just harder and messier. I'm still wondering if there is a solution.
Those graphics.c and graphics.h files are not part of pspsdk.
Everything in pspsdk should work with C++. Just remember there are numerous things to avoid with C++ on console hardware and it can be very easy to slaughter performance because of the extra cruft that can get added.
Everything in pspsdk should work with C++. Just remember there are numerous things to avoid with C++ on console hardware and it can be very easy to slaughter performance because of the extra cruft that can get added.
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
those files are from the lua graphic library.
(note these steps could require cygwin or similar program if you aren't in linux)
now the luaplayer use a c++ version of that library and to get it to work you need first to download from svn libjpeg and build/install it, then libpng and build/install, libz and build/install it finally the cpplibs and build at least the libpsp2d and install it into your enviroment.
After that download from svn the luaplayer and go in the src folder and take out from there the graphic.h, graphic.cpp, framebuffer.h, framebuffer.cpp.
make a makefile similar to this:
make it and you will obtain a libluagraphic.a lib.
copy it into the psp/lib folder and add to your apps the header file you copied before and use a string similar to this in the LIBS= declaration in the makefile of your apps
LIBS = -lluagraphicpp -lpsp2d -lstdc++ -ljpeg -lpng -lz -lpspgu -lm (add other libs also if you need them)
(note these steps could require cygwin or similar program if you aren't in linux)
now the luaplayer use a c++ version of that library and to get it to work you need first to download from svn libjpeg and build/install it, then libpng and build/install, libz and build/install it finally the cpplibs and build at least the libpsp2d and install it into your enviroment.
After that download from svn the luaplayer and go in the src folder and take out from there the graphic.h, graphic.cpp, framebuffer.h, framebuffer.cpp.
make a makefile similar to this:
Code: Select all
PSPDIR=$(PSPDEV)
TARGET_LIB = libluagraphicpp.a
OBJS = framebuffer.o graphics.o
CFLAGS = -O2 -G0
include $(PSPSDK)/lib/build.mak
copy it into the psp/lib folder and add to your apps the header file you copied before and use a string similar to this in the LIBS= declaration in the makefile of your apps
LIBS = -lluagraphicpp -lpsp2d -lstdc++ -ljpeg -lpng -lz -lpspgu -lm (add other libs also if you need them)
-
- Posts: 6
- Joined: Fri Jul 14, 2006 8:56 pm
I've try add CPP code in PSPSDK samples to compile them.
I've try add CPP code in PSPSDK samples to compile them. But I failed just now. The linker shows me some link error information about functions named likes sce*() in $(PSPSDK)\lib. So I guess we don't have the libary which compiled in CPP form. Maybe we should generate these lib files in CPP by myself? Can anyone help us?
-
- Posts: 6
- Joined: Fri Jul 14, 2006 8:56 pm
Maybe I have successed in compile them in CPP.
I've try to modify the samples code listed in the PSPSDK\samples\gu\cube. And wanna to make it can be compiled with psp-g++. Now, I make it successfully. But I have not try it on my babe PSP.
1, Add two OO source code file named cppTest.h & cppTest.cpp. Adjust the cube.c into cube.cpp. Because this file can be compiled with psp-g++ in only this way.
2, In cppTest.h & cppTest.cpp, I wrote a simple OO class and its implement.
3, In cube.cpp, include the file named cppTest.h and the important thing is add these code listed below:
and at the end of this file alse add:
OK, Now we can use the class in cube.cpp without any link error.
PS: I don't know how to update the src code in this forum. So sorry about I am not able to upload the code files.
1, Add two OO source code file named cppTest.h & cppTest.cpp. Adjust the cube.c into cube.cpp. Because this file can be compiled with psp-g++ in only this way.
2, In cppTest.h & cppTest.cpp, I wrote a simple OO class and its implement.
3, In cube.cpp, include the file named cppTest.h and the important thing is add these code listed below:
Code: Select all
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <pspgu.h>
#include <pspgum.h>
//! -- PA Here !!
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/callbacks.h"
#include "../common/vram.h"
#include "cppTest.h"
Code: Select all
sceKernelExitGame();
return 0;
}
//! -- PA Here!!
#ifdef __cplusplus
}
#endif
PS: I don't know how to update the src code in this forum. So sorry about I am not able to upload the code files.
Err, so in effect, you've wrapped the entire project in a "build it as C instead of C++". Not really C++ then, is it? The stuff in '../common/' shared by the gu-samples have not been written with C++ in mind so they won't work out of the box. I've updated the headers for these files in svn to work in a C++ environment, so they should work just fine from now on.
GE Dominator
-
- Posts: 6
- Joined: Fri Jul 14, 2006 8:56 pm
Oops, gu-samples won't works out of box?(Box? Sorry, I can't catch it because I'm a Chinese.). I just adjust the code can be compiled in CPP compiler(More compatible maybe). Maybe it also works all right. I will check it later. I use the devkitPro env in Win32 and I am not able to link the svn to get lastest PSPSDK.