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++

Problem with libc.a

Altera_Forum
Honored Contributor II
3,090 Views

Hi All, 

 

I&#39;ve got my Linux v1.1 up and running beautifully, but as soon as I try to compile ANYTHING that was not supplied by either ALTERA or MICROTRINIX I run into the same snag over and over again. libc.a – and it always gives the same error http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wacko.gif (Now If I were a cool hacker with a black belt in mystic karate I would probably have fixed the problem, but I’m still learning and don’t have much of a clue.) I can compile all the software in Linux and Cygwin natively but no luck in cross-compiling 

 

Ok that was a long intro here is the problem – does ANY-One know how I can work around it? Thanks in advance 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(closer.o): In function `_c 

lose_r&#39;: 

closer.o(.text+0x20): warning: _close is not implemented and will always fail 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(fstatr.o): In function `_f 

stat_r&#39;: 

fstatr.o(.text+0x28): warning: _fstat is not implemented and will always fail 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(makebuf.o): In function `_ 

_smakebuf&#39;: 

makebuf.o(.text+0xf8): warning: isatty is not implemented and will always fail 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(lseekr.o): In function `_l 

seek_r&#39;: 

lseekr.o(.text+0x2c): warning: _lseek is not implemented and will always fail 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(readr.o): In function `_re 

ad_r&#39;: 

readr.o(.text+0x2c): warning: _read is not implemented and will always fail 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(writer.o): In function `_w 

rite_r&#39;: 

writer.o(.text+0x2c): warning: _write is not implemented and will always fail 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libnosys.a(nosys_crt0.o): In func 

tion `__start_2&#39;:[/b] 

--- Quote End ---  

0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
1,985 Views

Hi. I&#39;d like to help but before we go too far, I need a few things clarified.... 

 

(1) you&#39;re trying to compile a Nios II Linux application? 

(2) Are you using the Microtronix Nios II Application Project type to build your app? 

(3) It looks like your app is trying to link against libc provided by Altera. Is this intentional? 

 

A few quick words before I sign off... 

 

All Nios II Linux applications should be linked against the uClibc to ensure the greatest amount of compatibility (instead of say glibc or newlib, etc). 

 

Other specialty libraries can be used as well but when trying to pull in the code for common functions such as open, close, read, write, etc... uClibc is your best bet. 

 

Creating a Nios II Linux application project in the Nios II IDE is a good place to start.
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

TO_BE_DONE

0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

Hi janhendrik, 

 

From your first message (see below), we can see you are using the wrong C library. You can use newlib when you build a standalone applicaiton, but if you want to build an application for uClinux, you have to use uClibc. The message shows that you are using newlib coming with the toolchain.  

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc 

-lib/nios2-elf/3.3.3/../../../../nios2-elf/lib/libc.a(closer.o): In function `_c 

lose_r&#39;:[/b] 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

Hi wentao, 

 

That is exactly what I thought, but now for the golden question. How do I link to the uClibc libraries? Where do I set what? The problem is that I did not write the Makefile http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif  

It is auto generated by automake and a bunch of other auto tools. Now I don’t know which arguments to pass to any of the auto tools to get it to generate a Makefile for the NIOS II. I don’t even know how to use the auto tools out of the IDE. 

 

From the SDK shell you just run ./autogen.sh and of it goes, BUT it generates a Makefile for the cygwin “sub”system. If I then change the compiler tools manually to the NIOS II toolchain I get the above mentioned errors. I have a suspicion that if you don’t pass library arguments to nios2-elf-gcc or nios2-build that it uses the newlib libraries by default, but I haven’t been able to test it since I don’t know the args to pass http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif  

 

Any suggestions and more info would help a heap  

 

Thanks everyone.
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

I recently discovered the Linux Forum part of niosforum.com 

< It’s accessible from the forum jump dropdown list > 

 

Since www.uclinux.org is currently down (From my location at least)  

I posted the oggplay source in the Linux forum.  

 

If ANYONE can get it to run on the NIOS II Linux 2.6 distribution, I’d love the feedback, because I can’t get it working http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif  

 

Just use your My Assistant to do a search for oggplay source and you’ll find it.  

 

Thanks everyone.
0 Kudos
Altera_Forum
Honored Contributor II
1,985 Views

Hi, I&#39;m sorry but in my experience, getting auto-gen scripts to cross-compile between architectures properly never seem to work very well for me. My recommendation would be to take a look at all the available options for the autogen script that you&#39;re using. 

 

Again, from experience, look for options that let you set: 

 

(1) the architecture (set to nios2-elf) 

(2) the location of the toolchain (to find the location of the toolchain, try "which nios2-elf-gcc") 

(3) the location of libc ($UCLIBC_PLUGIN/lib) 

(4) the location of the libc header files ($UCLIBC_PLUGIN/inc) 

 

Once all those are set, if the code for your library was designed well enough, then the library should compile. If not, then you&#39;ll need to start sifting through the generated Makefiles and working through some of the mechanics to figure out what went wrong. 

 

This is about as far as I can go in terms of providing free support. If you have any specific questions about location of files, or error messages, I might be able to help you. But I can&#39;t just start going through the files you provided, for that you would need to contact us (Microtronix) for an actual support contract of some sort. 

 

I hope this helps, and good luck.
0 Kudos
Reply