[En-Nut-Discussion] undefined reference to "NutAppMain" in C++ applications

Ralph Mason ralph.mason at telogis.com
Tue Oct 18 10:25:54 CEST 2005


You will need to make your NutMain extern "C" so that it doesn't name 
mangled.

Ralph
> Hello NutOS experts!
>
> I need a little advice concerning the following problem:
> I wrote an application in C++ (avr-gcc) which is roughly a TCP server.
> It worked nicely under NutOS 3.9.6. Now I updated to NutOS 3.9.8 and I'm 
> running into problems.
>
> The linker complains about the following:
>
> avr-gcc ethercai.o cai_irqcore.o cai_trigger.o cai_socket.o led.o 
> cai2_pollthread.o cai2_timer.o admin.o  crc.o -mmcu=atmega128 
> -Wl,--defsym=main=0,-Map=ethercai.map,--cref 
> -LD:/ethernut-3.9.8/nutbld/lib  D:/ethernut-3.9.8/nutbld/lib/nutinit.o 
> -lnutdev -lnutnet -lnutpro -lnutnet -lnutfs -lnutos -lnutdev -lnutcrt 
> -lnutos  -o ethercai.elf
> D:/ethernut-3.9.8/nutbld/lib/nutinit.o(.text+0x12): In function `NutIdle':
> : undefined reference to `NutAppMain'
> D:/ethernut-3.9.8/nutbld/lib/nutinit.o(.text+0x14): In function `NutIdle':
> : undefined reference to `NutAppMain'
> make: *** [ethercai.elf] Error 1
>
> I've found another thread in the mailing list which covers the same 
> problem (August 05 - "Compiler problem"). 
> The reason in that case seems only to be that 
> #define main    NutAppMain
> must be included somewhere (which resides in arch/avr.h)
>
> But in my case, this is not the solution. I think that "main" is been 
> translated into something weird like "_Z10_cxx_main_v" due to C++ name 
> mangling. 
> Therefore the above substitution does not work.
> What can I do?
>
> Thanks in advance,
>
> Christian
>
>
>
> _______________________________________________
> 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