Iostream Problem
Hi all,
I have recently posted a problem in the General Software Forum that I now know
applies to more specifically when using the eCos library. Here are the posts:
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)':
/build/nios2/bin/nios2-gnutools/src/gcc/libstdc++-v3/libsupc++/new:92: undefined reference to `_impure_ptr'
/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'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
================================================== ===
Hi all,
More information...
<attachment>
If anyone has a suggestion, I would really appreciate it.
Thanks,
Rennie
================================================== ===
I recently built the hello_world example as C++, i.e., I renamed the file to
hello_world.cpp and changed the contents to:
/*
* "Hello World" example.
*
* This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
* the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
* designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
* device in your system's hardware.
* The memory footprint of this hosted application is ~69 kbytes by default
* using the standard reference design.
*
* For a reduced footprint version of this template, and an explanation of how
* to reduce the memory footprint for a given application, see the
* "small_hello_world" template.
*
*/
//#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
// printf("Hello from Nios II!\n");
cout << "Hello from Nios II, iostream style!" << endl;
return 0;
}
If I build this as a Nios II only project (no eCos library specification), it builds
fine and runs fine. This implies that the problem lies with the use of iostream
functionality when using the eCos library that was built. I have followed the
instructions provided with the eCos installation for Nios II, but have not been
able to get past this problem. Any suggestions or help would be greatly
appreciated.
Thanks in advance!
Rennie