Does it support...

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

Moderators: cheriff, TyRaNiD

Post Reply
aniasis
Posts: 2
Joined: Wed Jun 29, 2005 4:09 am

Does it support...

Post by aniasis »

Does the SDK support STL?
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Have you tried it? Unfortunately the PSPSDK developers cannot test every configuration a user might use, and we can only fix or implement things once we know what's broken or missing.

Admittedly I haven't even tried compiling a C++ program, but the support for C++ and the the STL should be in psptoolchain (libstdc++ and newlib). What happens when you build a program using the STL?
emigree
Posts: 5
Joined: Mon May 09, 2005 5:29 am

Post by emigree »

I tried to convert sdktest to a cpp program by just renaming main.c to main.cpp but I get this error:

psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -I. -I/usr/local/p
spdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -c -o main.o mai
n.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/
pspdev/psp/sdk/lib main.o -lpspdebug -lpsplibc -lpspkernel -o cpptest.elf
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/crt0.o: In function `__e
ntrytable':
../../../sdk/startup/crt0.S:(.rodata.sceResident+0xc): undefined reference to `m
odule_info'
collect2: ld returned 1 exit status
make: *** [cpptest.elf] Error 1
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Yeah TyRaNiD found this one and I think he fixed it. If not a fix will be going into Subversion soon.

Just put extern in front of the definition of module_info (inside the PSP_MODULE_INFO macro) on line 62 of pspsdk/sdk/kernel/pspmoduleinfo.h.
emigree
Posts: 5
Joined: Mon May 09, 2005 5:29 am

Post by emigree »

Oh yes, I figured that out after fiddling a bit.

Now I'm having problems linking in libstdc++.

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L/usr/local/pspd
ev/psp/lib -L. -L/usr/local/pspdev/psp/sdk/lib -lstdc++ main.o -lpspdebug -lp
splibc -lpspkernel -o cpptest.elf
main.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x244): undefined reference to `std::ios_base::Init::~Init()'
main.cpp:(.text+0x24c): undefined reference to `std::ios_base::Init::Init()'
collect2: ld returned 1 exit status
make: *** [cpptest.elf] Error 1
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Order of object files matters to the GNU linker. Try putting -lstdc++ after main.o.
emigree
Posts: 5
Joined: Mon May 09, 2005 5:29 am

Post by emigree »

Yes I also thought that would be the problem. I've tried putting it before and after libc. That gave me alot of errors complaining about missing references to functions that should be in libc. Wich reminded me of reading that psplibc was just a limited set of functions. Then I tried defining this "USE_NEWLIB_LIBC = 1" but I still get alot of errors:

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L/usr/local/pspd
ev/psp/lib -L. -L/usr/local/pspdev/psp/sdk/lib main.o -lpspdebug -lc -lpspgl
ue -lpspkernel -lstdc++ -o cpptest.elf
/usr/local/pspdev/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/libc.a(writer.o): In function `_write_r':
../../../../../newlib/libc/reent/writer.c:58: undefined reference to `write'
/usr/local/pspdev/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/libc.a(fstatr.o): In function `_fstat_r':
../../../../../newlib/libc/reent/fstatr.c:62: undefined reference to `fstat'
/usr/local/pspdev/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/libc.a(readr.o): In function `_read_r':
../../../../../newlib/libc/reent/readr.c:58: undefined reference to `read'
/usr/local/pspdev/psp/lib/libstdc++.a(string-inst.o):/tmp/pspdev/gcc-4.0.0/build
-psp-c++/psp/libstdc++-v3/include/bits/char_traits.h:253: undefined reference to
`memcmp'
/usr/local/pspdev/psp/lib/libstdc++.a(string-inst.o): In function `compare':
/tmp/pspdev/gcc-4.0.0/build-psp-c++/psp/libstdc++-v3/include/bits/char_traits.h:
253: undefined reference to `memcmp'
/tmp/pspdev/gcc-4.0.0/build-psp-c++/psp/libstdc++-v3/include/bits/char_traits.h:
253: undefined reference to `memcmp'
/tmp/pspdev/gcc-4.0.0/build-psp-c++/psp/libstdc++-v3/include/bits/char_traits.h:
253: undefined reference to `memcmp'
/tmp/pspdev/gcc-4.0.0/build-psp-c++/psp/libstdc++-v3/include/bits/char_traits.h:
253: undefined reference to `memcmp'
/usr/local/pspdev/psp/lib/libstdc++.a(string-inst.o):/tmp/pspdev/gcc-4.0.0/build
-psp-c++/psp/libstdc++-v3/include/bits/char_traits.h:253: more undefined referen
ces to `memcmp' follow
/usr/local/pspdev/psp/lib/libstdc++.a(del_op.o): In function `operator delete(vo
id*)':
../../../../libstdc++-v3/libsupc++/del_op.cc:49: undefined reference to `free'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_personality.o): In function `base_of_en
coded_value':
/tmp/pspdev/gcc-4.0.0/libstdc++-v3/../gcc/unwind-pe.h:122: undefined reference t
o `abort'
/tmp/pspdev/gcc-4.0.0/libstdc++-v3/../gcc/unwind-pe.h:122: undefined reference t
o `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_personality.o): In function `read_encod
ed_value_with_base':
/tmp/pspdev/gcc-4.0.0/libstdc++-v3/../gcc/unwind-pe.h:259: undefined reference t
o `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_personality.o): In function `get_ttype_
entry':
/tmp/pspdev/gcc-4.0.0/libstdc++-v3/../gcc/unwind-pe.h:90: undefined reference to
`abort'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_terminate.o):../../../../libstdc++-v3/l
ibsupc++/eh_terminate.cc:44: undefined reference to `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_terminate.o):../../../../libstdc++-v3/l
ibsupc++/eh_terminate.cc:46: more undefined references to `abort' follow
/usr/local/pspdev/psp/lib/libstdc++.a(new_op.o): In function `operator new(unsig
ned int)':
../../../../libstdc++-v3/libsupc++/new_op.cc:57: undefined reference to `malloc'

../../../../libstdc++-v3/libsupc++/new_op.cc:68: undefined reference to `malloc'

/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:69: undefined reference to `fwrite'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:71: undefined reference to `fputs'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:74: undefined reference to `fwrite'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:73: undefined reference to `fputs'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:74: undefined reference to `fwrite'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:77: undefined reference to `free'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:51: undefined reference to `fwrite'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:52: undefined reference to `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:95: undefined reference to `fwrite'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:97: undefined reference to `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:97: undefined reference to `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:87: undefined reference to `fwrite'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:88: undefined reference to `fputs'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:89: undefined reference to `fputc'
/usr/local/pspdev/psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/lib
supc++/vterminate.cc:97: undefined reference to `abort'
/usr/local/pspdev/psp/lib/libstdc++.a(cp-demangle.o): In function `d_identifier'
:
cp-demangle.c:(.text+0x1538): undefined reference to `memcmp'
/usr/local/pspdev/psp/lib/libstdc++.a(cp-demangle.o): In function `d_print_resiz
e':
cp-demangle.c:(.text+0x3e18): undefined reference to `realloc'
cp-demangle.c:(.text+0x3e3c): undefined reference to `free'
/usr/local/pspdev/psp/lib/libstdc++.a(cp-demangle.o): In function `d_print_error
':
cp-demangle.c:(.text+0x4040): undefined reference to `free'
/usr/local/pspdev/psp/lib/libstdc++.a(cp-demangle.o): In function `d_print':
cp-demangle.c:(.text+0x40a4): undefined reference to `malloc'
/usr/local/pspdev/psp/lib/libstdc++.a(cp-demangle.o): In function `d_demangle':
cp-demangle.c:(.text+0x8fd8): undefined reference to `strncmp'
cp-demangle.c:(.text+0x9084): undefined reference to `malloc'
cp-demangle.c:(.text+0x9260): undefined reference to `strcat'
/usr/local/pspdev/psp/lib/libstdc++.a(cp-demangle.o): In function `__cxa_demangl
e':
cp-demangle.c:(.text+0x95cc): undefined reference to `strcpy'
cp-demangle.c:(.text+0x95d8): undefined reference to `free'
cp-demangle.c:(.text+0x95f4): undefined reference to `free'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_alloc.o):../../../../libstdc++-v3/libsu
pc++/eh_alloc.cc:115: undefined reference to `malloc'
/usr/local/pspdev/psp/lib/libstdc++.a(eh_alloc.o):../../../../libstdc++-v3/libsu
pc++/eh_alloc.cc:181: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2.o): In function `base_of
_encoded_value':
../../gcc/unwind-pe.h:122: undefined reference to `abort'
../../gcc/unwind-pe.h:122: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2.o): In function `read_en
coded_value_with_base':
../../gcc/unwind-pe.h:259: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2.o): In function `_Unwind
_GetGR':
../../gcc/unwind-dw2.c:146: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2.o): In function `_Unwind
_SetGR':
../../gcc/unwind-dw2.c:182: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2.o):../../gcc/unwind-dw2.
c:947: more undefined references to `abort' follow
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__r
egister_frame':
../../gcc/unwind-dw2-fde.c:119: undefined reference to `malloc'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__r
egister_frame_table':
../../gcc/unwind-dw2-fde.c:157: undefined reference to `malloc'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__d
eregister_frame_info_bases':
../../gcc/unwind-dw2-fde.c:216: undefined reference to `abort'
../../gcc/unwind-dw2-fde.c:201: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `__d
eregister_frame':
../../gcc/unwind-dw2-fde.c:234: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `sta
rt_fde_sort':
../../gcc/unwind-dw2-fde.c:402: undefined reference to `malloc'
../../gcc/unwind-dw2-fde.c:405: undefined reference to `malloc'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `end
_fde_sort':
../../gcc/unwind-dw2-fde.c:586: undefined reference to `free'
/usr/local/pspdev/lib/gcc/psp/4.0.0/libgcc.a(unwind-dw2-fde.o): In function `sea
rch_object':
../../gcc/unwind-dw2-fde.c:583: undefined reference to `abort'
collect2: ld returned 1 exit status
make: *** [cpptest.elf] Error 1


//----------------------------------------------------------------------

This is what I get when I put libstdc++ before libc:

//----------------------------------------------------------------------


psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -I. -I/usr/local/p
spdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -c -o main.o mai
n.cpp
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L/usr/local/pspd
ev/psp/lib -L. -L/usr/local/pspdev/psp/sdk/lib main.o -lstdc++ -lpspdebug -l
c -lpspglue -lpspkernel -o cpptest.elf
/usr/local/pspdev/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/libc.a(signalr.o): In function `_kill_r':
../../../../../newlib/libc/reent/signalr.c:61: undefined reference to `kill'
/usr/local/pspdev/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/libc.a(writer.o): In function `_write_r':
../../../../../newlib/libc/reent/writer.c:58: undefined reference to `write'
/usr/local/pspdev/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/libc.a(fstatr.o): In function `_fstat_r':
../../../../../newlib/libc/reent/fstatr.c:62: undefined reference to `fstat'
/usr/local/pspdev/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/libc.a(readr.o): In function `_read_r':
../../../../../newlib/libc/reent/readr.c:58: undefined reference to `read'
collect2: ld returned 1 exit status
make: *** [cpptest.elf] Error 1
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Newlib libc depends on "system calls" that we've implemented in PSPSDK's pspglue library. From your output, it looks like you haven't upgraded to the 0625 PSP toolchain, because it should be looking for those names with underscores in front of them.
Post Reply