Forum Discussion
Altera_Forum
Honored Contributor
20 years agoC++ Standard Libraries
Hi! I have started working with C++ in my project. Creating classes and using own objects is no problem, Now I want to use objects of the standard library, e.g. class "string", but I get lots of...
Altera_Forum
Honored Contributor
19 years ago --- Quote Start --- originally posted by mike desimone@Oct 5 2005, 12:22 PM actually, ecos supports stl just fine; this is a function of gcc and not ecos. it's just that the "-nostdlib" flag makes it not link the standard c++ library by default.
you need to add the "-lstdc++" flag to your link command, and it needs to be after all your .o files and any other libraries that use the stl.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=10180)
--- quote end ---
--- Quote End --- I have the same problem, and the -lstdc++ makes no difference. See below: make INSTALL_DIR=c:/Development/DefectAnalyzer/eCos/DspFull_Install all nios2-elf-gcc -nostartfiles -Lc:/Development/DefectAnalyzer/eCos/DspFull_Install/lib -Ttarget.ld -g -lstdc++ -Wl,--gc-sections -Wl,-static -mhw-mul -mhw-mulx -mno-hw-div -o hello hello.o hello.o(.gnu.linkonce.t._ZN9ExceptionD1Ev+0x68): In function `main': /cygdrive/c/altera/kits/nios2_60/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../../include/c++/3.4.1/bits/basic_string.h:178: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage' hello.o(.gnu.linkonce.t._ZN9ExceptionD1Ev+0x6c): In function `main': /cygdrive/c/Development/DefectAnalyzer/eCosProjects/examples/hello.cpp:30: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage' [etc.] Any ideas about what to try next?