Page 1 of 1

[Beginner Question] STL usage issues

Posted: Thu Nov 06, 2008 12:00 pm
by stoneCold
Hi ps2dev community,
First of all, thanks to all developers that contribute(d) their time and knowledge to create this GREAT! project ;)

However, just some days ago I started exploring the PS2 homebrew/indie development world, and I have to say I'm all excited.

Ok, got the PS2 Independence exploit working, downloaded the precompiled win32 version of the ps2dev sdk (from here), compiled one of the samples that come with it and ran it on my PS2 -> FUN !!

Now I'm trying to extend the samples / write my own programs and now to my first question (I tried to search for similar threads, but found no concrete answer, sry)...
Does the ps2dev sdk provide STL support? I saw that there are STL headers included in the package that I downloaded, but are they available for use?

When I tried to make use the the STL string class I got some serious compilation issues...
(sry, I'm a gcc/makefile newb, so I can't get much out of the error log)

My .cc file:

Code: Select all

#include <stdio.h>
#include <string>

int main&#40;int argc, char **argv&#41;
&#123;
	printf&#40;"START "&#41;;

	std&#58;&#58;string myStr = "myTestString";

	printf&#40;"EOP "&#41;;

	return 0;

&#125;
My makefile:

Code: Select all

EE_BIN = cpp-test.elf
EE_OBJS = cpp-test.o
EE_LIBS = -lstdc++ -ldraw -lgraph -lmath3d -lmf -lpacket -ldma

all&#58; $&#40;EE_BIN&#41;
	ee-strip --strip-all $&#40;EE_BIN&#41;

clean&#58;
	rm -f *.elf *.o *.a

include $&#40;PS2SDK&#41;/samples/Makefile.pref
include $&#40;PS2SDK&#41;/samples/Makefile.eeglobal
gcc output:

Code: Select all

C&#58;\ps2dev\ps2sdk\samples\cpp-test>make
ee-g++ -D_EE -O2 -G0 -Wall  -IC&#58;/ps2dev/ps2sdk/ee/include -IC&#58;/ps2dev/ps2sdk/common/include -I.  -c cpp-test.cc -o cpp-test.o
ee-gcc -mno-crt0 -TC&#58;/ps2dev/ps2sdk/ee/startup/linkfile -LC&#58;/ps2dev/ps2sdk/ee/lib  \
                -o cpp-test.elf C&#58;/ps2dev/ps2sdk/ee/startup/crt0.o cpp-test.o -lstdc++ -ldraw -lgraph -lmath3d -lmf -lpacket -ldma -lc -lkernel
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ios.o&#41;&#40;.text+0x178&#41;&#58;../../../../libstdc++-v3/libsupc++/new&#58;89&#58; undefined reference to `_impure_ptr'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ios.o&#41;&#40;.text+0x180&#41;&#58;../../../../libstdc++-v3/libsupc++/new&#58;89&#58; undefined reference to `_impure_ptr'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ios.o&#41;&#40;.text+0x198&#41;&#58;../../../../libstdc++-v3/libsupc++/new&#58;89&#58; undefined reference to `_impure_ptr'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ios.o&#41;&#40;.text+0x1a0&#41;&#58;../../../../libstdc++-v3/libsupc++/new&#58;89&#58; undefined reference to `_impure_ptr'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ios.o&#41;&#40;.text+0x1bc&#41;&#58;../../../../libstdc++-v3/libsupc++/new&#58;89&#58; undefined reference to `_impure_ptr'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ios.o&#41;&#40;.text+0x1c4&#41;&#58;../../../../libstdc++-v3/libsupc++/new&#58;89&#58; more undefined references to `_impure_ptr' follow
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale.o&#41;&#40;.text+0x1440&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/basic_string.h&#58;781&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_numERS3_S5_RiiijRKSt5ctypeIcERSt12_Ios_Iostate+0x1dc&#41;&#58; In function `__static_initialization_and_destruction_0'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/char_traits.h&#58;123&#58; undefined reference to `atoi'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZSt16__convert_from_vIdEiPciPKcT_RKPii+0x34&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/c++locale.h&#58;49&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZSt16__convert_from_vIdEiPciPKcT_RKPii+0x74&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/locale_facets.tcc&#58;2021&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZSt16__convert_from_vIdEiPciPKcT_RKPii+0xa0&#41;&#58; In function `__static_initialization_and_destruction_0'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/c++locale.h&#58;67&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZSt16__convert_from_vIeEiPciPKcT_RKPii+0x34&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/c++locale.h&#58;49&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZSt16__convert_from_vIeEiPciPKcT_RKPii+0x74&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/locale_facets.tcc&#58;2021&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;locale-inst.o&#41;&#40;.gnu.linkonce.t._ZSt16__convert_from_vIeEiPciPKcT_RKPii+0xa0&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/c++locale.h&#58;67&#58; more undefined references to `setlocale' follow
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;stl-inst.o&#41;&#40;.gnu.linkonce.t._ZNSt24__default_alloc_templateILb1ELi0EE8allocateEj+0xf4&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/bits/stl_alloc.h&#58;109&#58; undefined reference to `__assert'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;stl-inst.o&#41;&#40;.gnu.linkonce.t._ZNSaIcE8allocateEjPKv+0x110&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/gthr-single.h&#58;231&#58; undefined reference to `__assert'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;collate_members.o&#41;&#40;.text+0xc&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/collate_members.cc&#58;46&#58; undefined reference to `strcoll'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;collate_members.o&#41;&#40;.text+0x40&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/collate_members.cc&#58;54&#58; undefined reference to `strxfrm'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;time_members.o&#41;&#40;.text+0x38&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/time_members.cc&#58;47&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;time_members.o&#41;&#40;.text+0x50&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/time_members.cc&#58;48&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;time_members.o&#41;&#40;.text+0x64&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/time_members.cc&#58;49&#58; undefined reference to `strftime'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;time_members.o&#41;&#40;.text+0x70&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/time_members.cc&#58;50&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x1d4&#41;&#58; In function `void std&#58;&#58;__convert_to_v<long long>&#40;char const*, long long&, std&#58;&#58;_Ios_Iostate&, int* const&, int&#41;'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;89&#58; undefined reference to `strtoll'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x28c&#41;&#58; In function `void std&#58;&#58;__convert_to_v<unsigned long long>&#40;char const*, unsigned long long&, std&#58;&#58;_Ios_Iostate&, int* const&, int&#41;'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;106&#58; undefined reference to `strtoull'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x340&#41;&#58; In function `void std&#58;&#58;__convert_to_v<float>&#40;char const*, float&, std&#58;&#58;_Ios_Iostate&, int* const&, int&#41;'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;123&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x35c&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;124&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x38c&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;133&#58; undefined reference to `finitef'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x3c4&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;150&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x470&#41;&#58; In function `void std&#58;&#58;__convert_to_v<double>&#40;char const*, double&, std&#58;&#58;_Ios_Iostate&, int* const&, int&#41;'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;163&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x48c&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;164&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x4d8&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;172&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x570&#41;&#58; In function `void std&#58;&#58;__convert_to_v<long double>&#40;char const*, long double&, std&#58;&#58;_Ios_Iostate&, int* const&, int&#41;'&#58;
/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;185&#58; undefined reference to `setlocale'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;c++locale.o&#41;&#40;.text+0x58c&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/c++locale.cc&#58;186&#58; more undefined references to `setlocale' follow
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ctype.o&#41;&#40;.text+0x0&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/ctype_noninline.h&#58;38&#58; undefined reference to `_ctype_'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;ctype.o&#41;&#40;.text+0x8&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/include/ee/bits/ctype_noninline.h&#58;38&#58; undefined reference to `_ctype_'
/cygdrive/c/ps2dev/ee/bin/../lib/gcc-lib/ee/3.2.2/../../../../ee/lib/libstdc++.a&#40;basic_file.o&#41;&#40;.text+0x314&#41;&#58;/home/loser/toolchain/gcc-3.2.2/build-ee-c++/ee/libstdc++-v3/src/basic_file.cc&#58;100&#58; undefined reference to `setvbuf'
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;cpp-test.elf&#93; Error 1

C&#58;\ps2dev\ps2sdk\samples\cpp-test>
I would be very thankful for any info or help to get my makefile correct.

thx & cheers

Free MC Boot

Posted: Thu Nov 06, 2008 3:26 pm
by poutine
Hello stoneCold.
Ok, got the PS2 Independence exploit working
You might be interested by Free MC Boot then.

Danny

Posted: Thu Nov 06, 2008 6:28 pm
by ragnarok2040
I got this error as well when I was porting snes9x-1.51 without stlport. I'm pretty sure it's related to the string object, and might be related to general input/output streams. I'm still able to compile C++ programs though, as long as it uses C-style strings.

There's a stlport in the subversion repository... at svn://svn.ps2dev.org/ps2/trunk/ps2sdk-ports/stlport. It fixed the string object errors, but then I ran into some template errors.

I don't remember where I read this, but when linking with stlport, you should have these symbols defined in your EE_CXXFLAGS var.

EE_CXXFLAGS += -D_STLP_NO_NAMESPACES -D_NOTHREADS -D_STLP_NO_EXCEPTIONS -D_STLP_USE_NEWALLOC -D_STLP_HAS_WCHAR_T -D_STLP_NO_IOSTREAMS -Dwint_t=int -I$(PS2SDK)/ports/include/stlport/

Hope this helps, :D.

Posted: Fri Nov 07, 2008 5:53 am
by stoneCold
@ragnarok2040:

thx for the reply,
I tried to add the line you named to my makefile, but it didn't change anything regarding my error log :(

To clearify my question, the compilation issue is not related to the std::string class alone, I get (as far as I can see) the exactly same error log for other STL classes as well, for example if I try to use the vector template...

Code: Select all

#include <stdio.h>
#include <vector>

int main&#40;int argc, char **argv&#41;
&#123;
	printf&#40;"START "&#41;;

	std&#58;&#58;vector<int> myVec;

	printf&#40;"EOP "&#41;;

	return 0;

&#125;
... same error log :(

I tried to checkout the STL port that you mentioned, but I was unable to compile the source, seems the makefiles in there are no good for use on windows.

anyone an idea?

thx