- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello members of the forum... I am new working with Nios and programming applications C/C++ for that reason I please need the aid an expert who knows, wants and can help me to solve the errors of my small application of test,
The application:# include <stdio.h> int main(void){ printf("\nThis is a test of the application CPP2...bye\n"); return 0; } The error: make -k all no emulation specific options. nios2-elf-gcc -msys-crt0="c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib/crt0.o -r -d -L"c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib -o cpp2.bin cpp2.o /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/libm.a /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/libgcc.a "c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib/libc.a cpp2.o(.text+0x0): in function `_start':: multiple definition of `_start' c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/lib/crt0.o(.text+0x0): first defined here collect2: ld returned 1 exit status make: *** [cpp2.bin] Error 1 make: Target `all' not remade because of errors. I will thank for the aid of an expert who has knowledge about how to solve this problem.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi carol,
It is the startup crt0.o problem. It should be easier if you work on Linux and follow my buildroot guide, http://forum.niosforum.com/forum/index.php?showtopic=3174 (http://forum.niosforum.com/forum/index.php?showtopic=3174) The step8 in port#1 tells you how to compile and run a simple program on uClinux. About C++, you can not use nios2-elf's libstdc++, it is bond to newlib. On uClinux, you should need that which is bond to uClibc. The libstdc++ which we built with uClibc still have problems, it compiled and linked, but crashed when running on uClinux. I am not a C++ user, and I can't resolve the problems without help from C++ user.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hippo wrote....
--- Quote Start --- originally posted by hippo@Feb 24 2006, 11:55 AM the libstdc++ which we built with uclibc still have problems, it compiled and linked, but crashed when running on uclinux. --- Quote End --- Exactly, I'm getting this when I try to compile and link C++ on uClinux <div class='quotetop'>QUOTE </div> --- Quote Start --- # Compile the helloWorld app nios2-linux-uclibc-g++ hello.cpp -o hello -elf2flt /home/hootsmon/buildroot/build_nios2/staging_dir/bin-ccache/../lib/gcc/nios2-linux-uclibc/3.4.5/../../../../nios2-linux-uclibc/bin/ld.real: section .gnu.linkonce.sb._ZGVNSt7collateIcE2idE [0002dc40 -> 0002dc47] overlaps section .text [00000000 -> 0004d45f] /home/hootsmon/buildroot/build_nios2/staging_dir/bin-ccache/../lib/gcc/nios2-linux-uclibc/3.4.5/../../../../nios2-linux-uclibc/bin/ld.real: section .gnu.linkonce.sb._ZGVNSt8messagesIcE2idE [0002dc48 -> 0002dc4f] overlaps section .text [00000000 -> 0004d45f] etc....[/b] --- Quote End --- I spent some time digging into this problem, but I need some help please. Q) Can someone explain what W_RODATA and R_RODATA mean? I see these things get zapped by the Nios-specific linker script, but why? Grateful for any advice please.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I posted this to buildroot bug report, but they didn't accept it yet.
So download this and replace ~/buildroot/toolchain/elf2flt/elf2flt.nios2.conditional http://bugs.busybox.net/file_download.php?...id=601&type=bug (http://bugs.busybox.net/file_download.php?file_id=601&type=bug) And rebuild elf2fltcd ~/buildroot
rm -rf toolchain_build_nios2/elf2flt
make
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hippo, I did try try your bugfix, but unfortunately the link error is still there.
Here is my minimal C++ program...#include <iostream># include <stdio.h>
using namespace std;
int main()
{
printf ("Hello from STDIO\n"); // This works OK
cout << "Hello from IOSTREAM" << endl; // But this crashes linker!!!
return 0;
}
1) I have found that you can compile more-or-less any valid C code (with a CPP extension), so long as you don't link in any C++ specific stuff. 2) I tried both C++ compilers. (ie. nios2-linux-uclibc-c++ and nios2-linux-uclibc-g++), however they appear to be identical. 3) I'm guessing there's a problem in buildroot's libstdc++, but that's where I'm stumped. Can anyone explain how to run the DejaGnu testsuite, associated with libstdc++ ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hootsmon,
1. what's the link error messages now with libstdc++? can you link to elf without -elf2flt flag? try nios2-linux-uclibc-nm hello | sort , here hello is the elf without -elf2flt flag. 2. c++ and g++ are the same. 3. I guess there is problem in the elf2flt.ld, which should be rebuild from regular link script. I did bot run the test suits. If the hello can not run, it won't run the test suits either. The c++ is very different from c in class functions. I didn't have time to trace inside.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by hippo@Mar 7 2006, 05:06 PM 1. what's the link error messages now with libstdc++? --- Quote End --- The error messages say: "overlaps section...."
nios2-linux-uclibc-g++ hello.cpp -o hello -elf2flt
/home/hootsmon/buildroot/build_nios2/staging_dir/bin-ccache/../lib/gcc/nios2-linux-uclibc/3.4.5/../../../../nios2-linux-uclibc/bin/ld.real: section .gnu.linkonce.sb._ZGVNSt7collateIcE2idE overlaps section .text
/home/hootsmon/buildroot/build_nios2/staging_dir/bin-ccache/../lib/gcc/nios2-linux-uclibc/3.4.5/../../../../nios2-linux-uclibc/bin/ld.real: section .gnu.linkonce.sb._ZGVNSt8messagesIcE2idE overlaps section .text
--- Quote Start --- originally posted by hippo+mar 7 2006, 05:06 pm--><div class='quotetop'>quote (hippo @ mar 7 2006, 05:06 pm)</div> --- quote start ---
can you link to elf without -elf2flt flag?[/b]
--- quote end ---
yes, compiling --> elf works fine
<!--quotebegin-hippo@Mar 7 2006, 05:06 PM try nios2-linux-uclibc-nm hello | sort --- Quote End --- OK, I did this. Here are the symbols (compiled without -elf2flt).... http://users.bigpond.net.au/hootsmon/temp/sysmbols.txt (http://users.bigpond.net.au/hootsmon/temp/sysmbols.txt)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The result of elf seems OK.
There is onething I forgot to tell you. Please download some later snapshot of uClibc, after 20060208. eg, 20060214 or 20060215. and rebuild buildroot. cd ~/buildroot rm -rf build_nios2 toolchain_build_nios2 make- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For build0207, add a line at 117 of build_nios2/staging_dir/lib/elf2flt.ld ,
There is no need to rebuild buildroot.--- build_nios2/staging_dir/lib/elf2flt.ld 2006/03/08 02:10:19 1.1
+++ build_nios2/staging_dir/lib/elf2flt.ld 2006/03/08 02:21:44
@@ -114,6 +114,7 @@
*(.dynsbss)
*(.sbss)
*(.sbss.*)
+ *(.gnu.linkonce.sb*)
*(.scommon)
*(.dynbss)
*(.bss)
helloworld.cxx #include <iostream>
int main(int argc, char *argv)
{
std::cout << "Hello, world\n";
return 0;
}
nios2-linux-uclibc-c++ helloworld.cxx -o helloworld -elf2flt="-s 64000"
compiled and linked, but reboot when running on nios2 uclinux. Maybe I add the tag to the wrong place?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hippo, I took your advice and grabbed a uClibc snapshot from 20060214.
This is much better. Now my C++ program compiles and links cleanly. But when I execute, no output appears, and it just hangs (until I hit CTRL-C). So this is a hopeful sign. --- Quote Start --- originally posted by hippo@Mar 8 2006, 12:44 PM for build0207, add a line at 117 of build_nios2/staging_dir/lib/elf2flt.ld , --- Quote End --- I tried, but was unable to apply your patch. It seems my elf2flt.ld does not to match what was expected in the patch. Could could perhaps send me the whole elf2flt.ld script pls?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hootsmon,
find it in post#1 of the buildroot guide, elf2flt_ld.zip- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I tried out your elf2flt_ld script. I didn't patch it. Now the linker is getting some undefined references....
nios2-linux-uclibc-g++ hello.cpp -o hello -elf2flt="-s 64000"
hello.elf2flt(.text+0xc964): In function `__uClibc_fini':
: undefined reference to `__fini_array_start'
hello.elf2flt(.text+0xc968): In function `__uClibc_fini':
: undefined reference to `__fini_array_start'
hello.elf2flt(.text+0xc96c): In function `__uClibc_fini':
: undefined reference to `__fini_array_end'
I didn't try to execute it, 'cos it would probably crash anyway. Any thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are two versions of uClibc that we are talking about.
20060207 or 20060208, the older one, use the elf2flt.ld from elf2flt_ld.zip. 20060214 or later, the newer one with fini_array, use the patches which I post to busybox. But both will crash on libstdc++. I made the patches from normal elf ldscript. Maybe you can try to trace it out.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I got confused by this. I will try to trace it.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page