what language to start learning to code for psp?
what language to start learning to code for psp?
so, what language do i start learning to be able to code for psp? i have c/c++ books laying around do i need to learn c# or c or c++?
very dedicated and have many ideas. i know how to code in VB and just dieing to be able to make something work on psp with new language.
thanx in advance.
dragula96
very dedicated and have many ideas. i know how to code in VB and just dieing to be able to make something work on psp with new language.
thanx in advance.
dragula96
look around the forum.. there is a psp toolchain available that uses the gnu compilers.
of course, the libs that one might find in the official dev kit aren't available, but take a look at the front page of www.ps2dev.org, and you will find all you need to start coding.
of course, the libs that one might find in the official dev kit aren't available, but take a look at the front page of www.ps2dev.org, and you will find all you need to start coding.
in homebrew everything is in lower level languages, C or ASM. but when using the official dev kit its C, ASM, and C++. but its not likely that you will get the offical kit. i suggest getting a good understanding of C. ASM is good to know, but is not needed.
Also where to get kit. look around, the forum, there many sticky's explainning where and how to set it up. you have 2 choices, use the ps2sdk or the pspsdk, located in this site.
Also where to get kit. look around, the forum, there many sticky's explainning where and how to set it up. you have 2 choices, use the ps2sdk or the pspsdk, located in this site.
There are 10 types of people in the world: Those who understand binary, and those who don't...
C# would be a very bad idea to try to get to know if you are going to start homebrew. C# is a language that needs .Net installed, which obviously PSP does not have.
C would be a good bet to try and start next. It is easy enough to get the syntax of the language, and you dont have to worry about the object oriented designing of C++ (Although if you are 31337, you can use function pointers with structs to do oop ;) ). Compared to ASM, C will give you the basic foundation of most modern languages, and when you wish to learn a new one, it's pretty easy to add to your knowledge of C.
C would be a good bet to try and start next. It is easy enough to get the syntax of the language, and you dont have to worry about the object oriented designing of C++ (Although if you are 31337, you can use function pointers with structs to do oop ;) ). Compared to ASM, C will give you the basic foundation of most modern languages, and when you wish to learn a new one, it's pretty easy to add to your knowledge of C.
yes thats true, but its not recommended. and as far as i know, its not fully supported. But again to answer the question, start off with C. learning C++ is good too.MrHTFord wrote:That's not correct. C++ can be used with homebrew.in homebrew everything is in lower level languages, C or ASM. but when using the official dev kit its C, ASM, and C++.
There are 10 types of people in the world: Those who understand binary, and those who don't...
I hereby recommend that anyone who wants to program C++ on psp can and should.yes thats true, but its not recommended. and as far as i know, its not fully supported.
As for support, will the moral variety suffice? If so, here it is:
"Go for it! code in C++ you super object oriented programmer!"
;-)
I dont want to start an argument here, but here is what I have to say. Learning C should be your first step before learning C++. I had tried doing it the other way, and I knew how to code silly little examples in C++, but a lot of the details of what the language was doin was hidden from me. The OOP of C++ is nice, but really, unless you are going to be doing some major development, OOP is NOT a necesity, and sometimes just too much. After learning C, I had a much better understanding of what the language is doing with the memory management of the system.MrHTFord wrote: I hereby recommend that anyone who wants to program C++ on psp can and should.
I believe that a solid foundation in C is such a great jumpstart into learning C++, but C++ definately should not be your first language (and sorry for me offending anyone by saying this, but VB isn't a real language, at least not imo, which is why I disregard him saying he knows it).
C++ with psp toolchain
I have been coding c with the psp toolchain successfully, but would very much like to be able to write in c++.
My current attempts have been unsuccessfull since I can't seem to get my code to link :(
psp-ld keeps throwing "undefined reference to `__gxx_personality_v0'", in my face. Also setting class destructors as virtual adds an "undefined reference to `operator delete(void*)'" to the list of errors.
My build script looks something like this:
/usr/local/pspdev/psp/bin/psp-g++ -march=r4000 -g -mgp32 -mlong32 -c Main.cpp
/usr/local/pspdev/psp/bin/psp-g++ -march=r4000 -g -mgp32 -mlong32 -c Foo.cpp
/usr/local/pspdev/psp/bin/psp-g++ -march=r4000 -g -mgp32 -xassembler -c -O -o startup.o startup.s
/usr/local/pspdev/psp/bin/psp-ld -O0 startup.o Main.o Foo.o -v -M -Ttext 8900000 -o out > CppApp.map
Main.cpp only contains the main method, which instanciates Foo. Foo is an completely empty class with only a constructor.
Anything obvious I have missed here?
My current attempts have been unsuccessfull since I can't seem to get my code to link :(
psp-ld keeps throwing "undefined reference to `__gxx_personality_v0'", in my face. Also setting class destructors as virtual adds an "undefined reference to `operator delete(void*)'" to the list of errors.
My build script looks something like this:
/usr/local/pspdev/psp/bin/psp-g++ -march=r4000 -g -mgp32 -mlong32 -c Main.cpp
/usr/local/pspdev/psp/bin/psp-g++ -march=r4000 -g -mgp32 -mlong32 -c Foo.cpp
/usr/local/pspdev/psp/bin/psp-g++ -march=r4000 -g -mgp32 -xassembler -c -O -o startup.o startup.s
/usr/local/pspdev/psp/bin/psp-ld -O0 startup.o Main.o Foo.o -v -M -Ttext 8900000 -o out > CppApp.map
Main.cpp only contains the main method, which instanciates Foo. Foo is an completely empty class with only a constructor.
Anything obvious I have missed here?
First, get rid of -march=r4000 -mgp32 -mlong32. The -march is wrong for the PSP toolchain and the other two are redundant.
The __gxx_personaility_v0 comes from the use of exceptions. If you aren't using exceptions you should compile all of your code with -fno-exceptions. It' s usually a good idea to compile with -fno-rtti also.
Finally, you should always use either psp-gcc or psp-g++ to link your programs. You would only need to use psp-ld if you have an extremely nonstandard way of linking your program. So change the psp-ld line to:
The -Wl is necessary to pass special commands to the linker. psp-gcc does recognize some psp-ld commands, but some of the more obscure ones may require prefixing them with -Wl.
The __gxx_personaility_v0 comes from the use of exceptions. If you aren't using exceptions you should compile all of your code with -fno-exceptions. It' s usually a good idea to compile with -fno-rtti also.
Finally, you should always use either psp-gcc or psp-g++ to link your programs. You would only need to use psp-ld if you have an extremely nonstandard way of linking your program. So change the psp-ld line to:
Code: Select all
psp-g++ startup.o Main.o Foo.o -Wl,-Ttext -Wl,8900000 -o out
Thank you for the help!! It worked...
Trying to use stl in the code, did however bring up a new link issue :/
By adding something like this...
I get the following error when linking:
Any help appreciated...
Trying to use stl in the code, did however bring up a new link issue :/
By adding something like this...
Code: Select all
std::list<Foo*> lst;
lst.push_back( new Foo() );
Code: Select all
undefined reference to `std::__throw_bad_alloc()'
undefined reference to `operator new(unsigned int)'
undefined reference to `std::_List_node_base::hook(std::_List_node_base*)'
Code: Select all
/usr/local/pspdev/psp/bin/psp-gcc startup.o Foo.o -Wl,-Ttext -Wl,8900000 -o out -lc > CppApp.map
Adding -lstdc++ gives a whole bunch of new undefined references:
Code: Select all
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(abort.o): In function `abort':
../../../../../newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(sbrkr.o): In function `_sbrk_r':
../../../../../newlib/libc/reent/sbrkr.c:60: undefined reference to `sbrk'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(signalr.o): In function `_kill_r':
../../../../../newlib/libc/reent/signalr.c:61: undefined reference to `kill'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(signalr.o): In function `_getpid_r':
../../../../../newlib/libc/reent/signalr.c:96: undefined reference to `getpid'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(makebuf.o): In function `__smakebuf':
../../../../../newlib/libc/stdio/makebuf.c:96: undefined reference to `isatty'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(writer.o): In function `_write_r':
../../../../../newlib/libc/reent/writer.c:58: undefined reference to `write'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(closer.o): In function `_close_r':
../../../../../newlib/libc/reent/closer.c:53: undefined reference to `close'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(fstatr.o): In function `_fstat_r':
../../../../../newlib/libc/reent/fstatr.c:62: undefined reference to `fstat'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(lseekr.o): In function `_lseek_r':
../../../../../newlib/libc/reent/lseekr.c:58: undefined reference to `lseek'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a(readr.o): In function `_read_r':
../../../../../newlib/libc/reent/readr.c:58: undefined reference to `read'