| View previous topic :: View next topic |
| Author |
Message |
dragula96
Joined: 17 Jun 2005 Posts: 21
|
Posted: Fri Jun 17, 2005 4:49 pm Post subject: 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 |
|
| Back to top |
|
 |
wulf
Joined: 13 Apr 2005 Posts: 81
|
Posted: Fri Jun 17, 2005 4:57 pm Post subject: |
|
|
learn c, and learn assembly for MIPS.
also search the forum, try to read every post, even the ones for PS2, you'll learn a lot.
welcome to the forum! |
|
| Back to top |
|
 |
netddos
Joined: 17 Jun 2005 Posts: 9
|
Posted: Fri Jun 17, 2005 5:11 pm Post subject: |
|
|
suppose you code something in c and assembly..
where is the psp dev kit? |
|
| Back to top |
|
 |
wulf
Joined: 13 Apr 2005 Posts: 81
|
Posted: Fri Jun 17, 2005 5:41 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Thanhda

Joined: 09 Apr 2005 Posts: 331 Location: Canada
|
Posted: Fri Jun 17, 2005 6:07 pm Post subject: |
|
|
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. _________________ There are 10 types of people in the world: Those who understand binary, and those who don't... |
|
| Back to top |
|
 |
Agoln

Joined: 08 Jun 2005 Posts: 326 Location: Fort Wayne, IN
|
Posted: Fri Jun 17, 2005 11:33 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
MrHTFord
Joined: 10 Feb 2004 Posts: 35 Location: England
|
Posted: Fri Jun 17, 2005 11:40 pm Post subject: |
|
|
| Quote: |
in homebrew everything is in lower level languages, C or ASM. but when using the official dev kit its C, ASM, and C++.
|
That's not correct. C++ can be used with homebrew. |
|
| Back to top |
|
 |
Thanhda

Joined: 09 Apr 2005 Posts: 331 Location: Canada
|
Posted: Sat Jun 18, 2005 1:16 am Post subject: |
|
|
| MrHTFord wrote: | | Quote: |
in homebrew everything is in lower level languages, C or ASM. but when using the official dev kit its C, ASM, and C++.
|
That's not correct. C++ can be used with homebrew. |
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. _________________ There are 10 types of people in the world: Those who understand binary, and those who don't... |
|
| Back to top |
|
 |
MrHTFord
Joined: 10 Feb 2004 Posts: 35 Location: England
|
Posted: Sat Jun 18, 2005 4:35 am Post subject: |
|
|
| Quote: | | yes thats true, but its not recommended. and as far as i know, its not fully supported. |
I hereby recommend that anyone who wants to program C++ on psp can and should.
As for support, will the moral variety suffice? If so, here it is:
"Go for it! code in C++ you super object oriented programmer!"
;-) |
|
| Back to top |
|
 |
Agoln

Joined: 08 Jun 2005 Posts: 326 Location: Fort Wayne, IN
|
Posted: Sat Jun 18, 2005 5:40 am Post subject: |
|
|
| MrHTFord wrote: |
I hereby recommend that anyone who wants to program C++ on psp can and should. |
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.
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). |
|
| Back to top |
|
 |
th0mas
Joined: 24 Apr 2005 Posts: 43 Location: Canada
|
Posted: Sat Jun 18, 2005 5:53 am Post subject: |
|
|
Agoln:
you're taking his quote out of context. He was debunking the previous post's claim that c++ programming wouldn't work properly with the toolchain and end in tears, not that you should learn c++ before c. _________________ http://th0mas.xbox-scene.com |
|
| Back to top |
|
 |
medley
Joined: 18 Jun 2005 Posts: 4
|
Posted: Sat Jun 18, 2005 8:34 am Post subject: 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? |
|
| Back to top |
|
 |
MrHTFord
Joined: 10 Feb 2004 Posts: 35 Location: England
|
Posted: Sat Jun 18, 2005 9:12 am Post subject: |
|
|
Yes,
You need to link newlib's libstdc++.a |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Jun 18, 2005 9:13 am Post subject: |
|
|
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:
| Code: | | psp-g++ startup.o Main.o Foo.o -Wl,-Ttext -Wl,8900000 -o out |
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. |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sat Jun 18, 2005 9:14 am Post subject: |
|
|
| MrHTFord wrote: | Yes,
You need to link newlib's libstdc++.a |
newlib doesn't ship with libstdc++, GCC does, but he shouldn't be using psp-ld to link with anyway. |
|
| Back to top |
|
 |
medley
Joined: 18 Jun 2005 Posts: 4
|
Posted: Sun Jun 19, 2005 2:58 am Post subject: |
|
|
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...
| Code: | std::list<Foo*> lst;
lst.push_back( new Foo() ); |
I get the following error when linking:
| Code: | 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: | | /usr/local/pspdev/psp/bin/psp-gcc startup.o Foo.o -Wl,-Ttext -Wl,8900000 -o out -lc > CppApp.map |
Any help appreciated... |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sun Jun 19, 2005 3:03 am Post subject: |
|
|
| Change psp-gcc to psp-g++ or add -lstdc++ (before -lc) to the link command line. |
|
| Back to top |
|
 |
medley
Joined: 18 Jun 2005 Posts: 4
|
Posted: Sun Jun 19, 2005 4:13 am Post subject: |
|
|
Adding -lstdc++ gives a whole bunch of new undefined references:
| Code: | /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'
|
|
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Sun Jun 19, 2005 10:57 am Post subject: |
|
|
| Oops. That will be fixed when pspsdk is released. For now just define a bunch of stub functions with the names of the ones it's complaining about. |
|
| Back to top |
|
 |
|