[ECOS] Howto get basic STL running

Øyvind Harboe oyvind.harboe@zylin.com
Fri Jan 16 15:17:00 GMT 2004


I get the impression that there are people out there that use STL
w/eCos. There are numerous posts that hint as much in ecos-discuss, but
I didn't find any "howto".



Specifically I'm interested in "class string".




This is how far I got:


--- test app ---

#include <stdio.h>
void remove();
void rename();
void tmpfile();
void tmpnam();
#include <memory>
#include <string>

void test()
{
	std::string xx="abc";
//	string yy=xx+"kljasdf";
}


--- test app ---

Once I twisted the arm of GCC to compile the thing, I got these linking
errors:

---- linking errors ----

output/./xxx.o: In function `test()':
/cygdrive/c/e21/workspace/firmware/xxx.cc:13: undefined reference to
`std::allocator<char>::allocator[in-charge]()'
/cygdrive/c/e21/workspace/firmware/xxx.cc:13: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string[in-charge](char const*, std::allocator<char> const&)'
/cygdrive/c/e21/workspace/firmware/xxx.cc:13: undefined reference to
`std::allocator<char>::~allocator [in-charge]()'
/cygdrive/c/e21/workspace/firmware/xxx.cc:13: undefined reference to
`std::allocator<char>::~allocator [in-charge]()'
/cygdrive/c/e21/workspace/firmware/xxx.cc:13: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::~basic_string [in-charge]()'
collect2: ld returned 1 exit status
make: *** [output/rimi.bin] Error 1

---- linking errors ----


After a bit of googling, I discovered that I was missing various things
in libstdc++ that explicitly instantiates templates, e.g.:


http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/gcc/gcc/libstdc++-v3/src/allocator-inst.cc?rev=HEAD&content-type=text/plain


Although I could make some linker errors disappear as I pasted in bits
of code from the savannah CVS, I was always left with a couple of more
linker errors...


Øyvind



-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list