what language to start learning to code for psp?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
dragula96
Posts: 21
Joined: Fri Jun 17, 2005 4:46 pm

what language to start learning to code for psp?

Post by dragula96 »

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
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »

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!
netddos
Posts: 9
Joined: Fri Jun 17, 2005 4:03 pm

Post by netddos »

suppose you code something in c and assembly..

where is the psp dev kit?
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »

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.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

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...
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

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.
MrHTFord
Posts: 35
Joined: Tue Feb 10, 2004 2:04 am
Location: England

Post by MrHTFord »

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.
User avatar
Thanhda
Posts: 331
Joined: Sat Apr 09, 2005 2:08 am
Location: Canada
Contact:

Post by Thanhda »

MrHTFord wrote:
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...
MrHTFord
Posts: 35
Joined: Tue Feb 10, 2004 2:04 am
Location: England

Post by MrHTFord »

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!"

;-)
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

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).
th0mas
Posts: 43
Joined: Sun Apr 24, 2005 1:59 am
Location: Canada
Contact:

Post by th0mas »

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.
medley
Posts: 4
Joined: Sat Jun 18, 2005 8:08 am

C++ with psp toolchain

Post by medley »

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?
MrHTFord
Posts: 35
Joined: Tue Feb 10, 2004 2:04 am
Location: England

Post by MrHTFord »

Yes,

You need to link newlib's libstdc++.a
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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: Select all

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.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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.
medley
Posts: 4
Joined: Sat Jun 18, 2005 8:08 am

Post by medley »

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: Select all

std&#58;&#58;list<Foo*> lst;
lst.push_back&#40; new Foo&#40;&#41; &#41;;
I get the following error when linking:

Code: Select all

undefined reference to `std&#58;&#58;__throw_bad_alloc&#40;&#41;'
undefined reference to `operator new&#40;unsigned int&#41;'
undefined reference to `std&#58;&#58;_List_node_base&#58;&#58;hook&#40;std&#58;&#58;_List_node_base*&#41;'

Code: Select all

/usr/local/pspdev/psp/bin/psp-gcc startup.o Foo.o -Wl,-Ttext -Wl,8900000 -o out -lc > CppApp.map
Any help appreciated...
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Change psp-gcc to psp-g++ or add -lstdc++ (before -lc) to the link command line.
medley
Posts: 4
Joined: Sat Jun 18, 2005 8:08 am

Post by medley »

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&#40;abort.o&#41;&#58; In function `abort'&#58;
../../../../../newlib/libc/stdlib/abort.c&#58;63&#58; undefined reference to `_exit'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;sbrkr.o&#41;&#58; In function `_sbrk_r'&#58;
../../../../../newlib/libc/reent/sbrkr.c&#58;60&#58; undefined reference to `sbrk'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;signalr.o&#41;&#58; In function `_kill_r'&#58;
../../../../../newlib/libc/reent/signalr.c&#58;61&#58; undefined reference to `kill'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;signalr.o&#41;&#58; In function `_getpid_r'&#58;
../../../../../newlib/libc/reent/signalr.c&#58;96&#58; undefined reference to `getpid'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;makebuf.o&#41;&#58; In function `__smakebuf'&#58;
../../../../../newlib/libc/stdio/makebuf.c&#58;96&#58; undefined reference to `isatty'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;writer.o&#41;&#58; In function `_write_r'&#58;
../../../../../newlib/libc/reent/writer.c&#58;58&#58; undefined reference to `write'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;closer.o&#41;&#58; In function `_close_r'&#58;
../../../../../newlib/libc/reent/closer.c&#58;53&#58; undefined reference to `close'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;fstatr.o&#41;&#58; In function `_fstat_r'&#58;
../../../../../newlib/libc/reent/fstatr.c&#58;62&#58; undefined reference to `fstat'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;lseekr.o&#41;&#58; In function `_lseek_r'&#58;
../../../../../newlib/libc/reent/lseekr.c&#58;58&#58; undefined reference to `lseek'
/usr/local/pspdev/psp/lib/gcc/psp/4.0.0/../../../../psp/lib/libc.a&#40;readr.o&#41;&#58; In function `_read_r'&#58;
../../../../../newlib/libc/reent/readr.c&#58;58&#58; undefined reference to `read'
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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.
Post Reply