[En-Nut-Discussion] Multiple definition of free and malloc

Harald Kipp harald.kipp at egnite.de
Mon Jun 13 12:22:46 CEST 2005


Hi Stephan,

avr-gcc uses a one-pass linker. In some situations you have to
add a lib twice. So, simply add -lnutcrt once more at the end
of the list.

Beside that, I tried to replace NutHeapAlloc/Free at several
places in the kernel to make it look more familiar. Actually
this wasn't a good idea. Now even app/simple needs to be linked
to libnutcrt.a. I'll revert these changes. That doesn't mean,
it should be replaced everywhere. For example, most modules
in pro/ use libnutcrt.a anyway (printf etc.) and should prefer
the standard functions (malloc/calloc/free).

Harald

At 11:58 13.06.2005 +0200, you wrote:
>Hi everybody,
>
>when I try to link my ethernut program I get a linker error that malloc
>and free are defined twice(in libc.a and libnutcrt.a).
>
>I'm linking my program this way:
>
>avr-gcc -mmcu=atmega128 -Wl,--defsym=main=0,-Map=./obj/myprog.map,--cref
>-L~/nut/lib ./obj/*.o ~/nut/lib/nutinit.o -lnutos -lnutcrt -lnutdev
>-lnutfs -lnutnet -lnutos -lnutpro -lnutcpp -o obj/myprog.elf
>
>I already tried to change the order of the -l arguments and I also tried
>to use -nostdlib and -nodefaultlibs but that produced a lot of undefined
>definitions.
>
>thanks for your help,
>
>stephan
>--
>
>_______________________________________________
>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