Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Iostream Problem

Altera_Forum
Honored Contributor II
1,073 Views

Hi, 

 

I have recently been using the Nios II v6.0 tools and downloaded and installed 

the eCos implementation for Neos. I went through the documentation for creating 

the eCos library and building and running the examples included with eCos. All 

worked fine. Then, I started slowly porting some existing code to the new platform 

and ran into some issues. For the sake of narrowing down the problems, I went 

back to the eCos examples and created a new file, hello.cpp: 

 

/* this is a simple hello world program */# include <iostream> 

 

using namespace std; 

 

int main(void) 

cout << "Hello, eCos world!" << endl; 

return 0; 

 

The file compiles fine, but I get an error on the link: 

 

nios2-elf-gcc -nostartfiles -L/cygdrive/c/altera/ecos/eqam_install/lib -Ttarget.ld -g -nostdlib -Wl,--gc-sections -Wl,-static -mhw-mul -mno-hw-mulx -mno-hw-div -o hello hello.o -lstdc++ 

/cygdrive/c/altera/kits/nios2_60/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/libstdc++.a(ios_init.o)(.text+0x31c): In function `std::ios_base::sync_with_stdio(bool)&#39;: 

/build/nios2/bin/nios2-gnutools/src/gcc/libstdc++-v3/libsupc++/new:92: undefined reference to `_impure_ptr&#39; 

/cygdrive/c/altera/kits/nios2_60/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/libstdc++.a(ios_init.o)(.text+0x31c):/build/nios2/bin/nios2-gnutools/src/gcc/libstdc++-v3/libsupc++/new:92: Unable to reach _impure_ptr (at 0x00000000) from the global pointer (at 0x04041e7c) because the offset (-67378812) is out of the allowed range, -32678 to 32767. 

 

Any help that could be provided would be greatly appreciated. 

 

Thanks! 

Rennie 

 

P.S. For the sake of completeness, here&#39;s the compiler command and output: 

 

nios2-elf-gcc -c -o hello.o -I/cygdrive/c/altera/ecos/eqam_install/include -g -O3 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -DSYSTEM_BUS_WIDTH=32 -mhw-mul -mno-hw-mulx -mno-hw-div hello.cpp 

cc1plus: warning: switch "-fvtable-gc" is no longer supported
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
347 Views

Hi all, 

 

More information... I was able to get this far (errors regarding "impure pointer" 

during link) only after changing a setting in my setup using the eCos Configuration 

Tool. The setting I changed was under "ISO C Library", "ISO C Library internationalization functions". I enabled "Newlib&#39;s ctype implementation". Prior 

to that I was using the defaults, which did not have this option selected. Instead, it 

had "Inline versions of <ctype.h> functions" selected. But using this default 

selection, I had a different set of errors, this time during compilation. They were: 

 

make INSTALL_DIR=/cygdrive/c/altera/ecos_library/eqam_install all  

nios2-elf-gcc -c -o hello.o -I/cygdrive/c/altera/ecos_library/eqam_install/include -g -O3 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -DSYSTEM_BUS_WIDTH=32 -mhw-mul -mno-hw-mulx -mno-hw-div hello.cpp 

cc1plus: warning: switch "-fvtable-gc" is no longer supported 

In file included from /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/locale_facets.h:132, 

from /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_ios.h:44, 

from /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/ios:51, 

from /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/ostream:45, 

from /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/iostream:45, 

from hello.cpp:2: 

/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/nios2-elf/bits/ctype_base.h:46: error: `_U&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:47: error: `_L&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:48: error: `_U&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:48: error: `_L&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:49: error: `_N&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:50: error: `_X&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:50: error: `_N&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:51: error: `_S&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:52: error: `_P&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:52: error: `_U&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:52: error: `_L&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:52: error: `_N&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:52: error: `_B&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:53: error: `_P&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:53: error: `_U&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:53: error: `_L&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:53: error: `_N&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:54: error: `_C&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:55: error: `_P&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:56: error: `_U&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:56: error: `_L&#39; was not declared in this scope 

/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/nios2-elf/bits/ctype_base.h:56: error: `_N&#39; was not declared in this scope 

make: *** [hello.o] Error 1 

 

If anyone has a suggestion, I would really appreciate it. 

 

Thanks, 

Rennie
0 Kudos
Reply