[En-Nut-Discussion] freopen: undefined reference

amit khandelwal khandelwal.amit at gmail.com
Tue Mar 29 19:28:39 CEST 2005


Actually you need the -lnutcrt ( freopen is defined there)  - check
out the list of libraries that I mentioned in my old email -


On Tue, 29 Mar 2005 12:25:35 -0500, amit khandelwal
<khandelwal.amit at gmail.com> wrote:
> Hello,
>     I see that you are linking to the nutinit.o file -
> 
> a typical command would look like this -
> 
> avr-gcc tcps.o  -mmcu=atmega128
> -Wl,--defsym=main=0,-Map=tcps.map,--cref -L../../lib/gcc/atmega128
> ../../lib/gcc/atmega128/nutinit.o  -lnutdev -lnutnet -lnutpro -lnutnet
> -lnutfs -lnutos -lnutdev -lnutcrt -lnutos -o tcps.elf
> 
> hth,
> 
> -Amit Khandelwal
> 
> 
> On Tue, 29 Mar 2005 17:08:42 +0000, Arjan Vroegop <atjev at hotmail.com> wrote:
> > Hi!
> >
> > I'm trying to control a LCD with a Ethernut 1.3g board. I tried the
> > following code, which comes from the ethernut software manual:
> >
> > #include <stdio.h>
> > #include <dev/hd44780.h>
> > #include <dev/term.h>
> > int main(void)
> > {
> > /* Register the device we want to use. */
> > NutRegisterDevice(&devLcd, 0, 0);
> > /* Assign the device to stdout. */
> > freopen("lcd", "w", stdout);
> > printf("Hello world!\n");
> > }
> >
> > When I compile the program with avrgcc I get the following error:
> >
> > make install
> > avr-gcc main.o -mmcu=atmega128 -Wl,--defsym=main=0,-Map=main.map,--cref
> > -Lc:/eth
> > ernut/build/lib  c:/ethernut/build/lib/nutinit.o -lnutos -lnutdev  -o
> > main.elf
> > main.o(.text+0x1e): In function `NutAppMain':
> > : undefined reference to `freopen'
> > make: *** [main.elf] Error 1
> >
> > I think it's a problem with the linking. I tried to find information about
> > this problem on the internet, I saw something about the .map file. This file
> > contains the following line:
> >
> > freopen                                           main.o
> >
> > I assume this means that the linker looks for freopen in main.o, which
> > obviously isn't there. Is there anybody who know how to fix this?
> >
> > Thanks in advance,
> > Arjan Vroegop
> >
> > _________________________________________________________________
> > Express yourself instantly with MSN Messenger! Download today - it's FREE!
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> >
> > _______________________________________________
> > En-Nut-Discussion mailing list
> > En-Nut-Discussion at egnite.de
> > http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
> >
>



More information about the En-Nut-Discussion mailing list