[En-Nut-Discussion] C++ and Uart

Stephan Uhle stephan.uhle at alcatel.de
Tue May 10 17:04:37 CEST 2005


Hi everybody,

I'm a relative newbie to ethernut and just trying to build up a serial
communication between my Charon II Board and my PC.
When I use C everything works fine but when using C++ I get the following
linker-error:

serial.o(.text+0x1e): In function `_cxx_main_()':
: undefined reference to `freopen(char const*, char const*, __iobuf*)'

This is my program:

#include <dev/uartavr.h>
#include <stdio.h>
                                                                            
                                                
#include <cpp/nutcpp.h>
                                                                            
                                                
int main(void)
{
   NutRegisterDevice(&devUart0, 0, 0);
   freopen("uart0","w",stdout);
   printf("Hello world\n");
                                                                            
                                                
   for(;;);
}

and this is the way I compile:

$ avr-gcc -mmcu=atmega128 -Os -Wall -Wstrict-prototypes -I~/nut/include -c
serial.cpp

and link...

$ avr-gcc serial.o  -mmcu=atmega128
-Wl,--defsym=main=0,-Map=serial.map,--cref -L~/nut/lib ~/nut/lib/nutinit.o
-lnutos -lnutcrt -lnutdev -lnutfs -lnutnet -lnutos -lnutpro -lnutcrt
-lnutcpp -o serial.elf

I'm using the cvs - version of April 19th 2005 on Redhat 9.

Did I just forget to add a specific library or header-file?


Thanks in advance,

Stephan
-- 




More information about the En-Nut-Discussion mailing list