Avr-gcc(4.4.2)/avr-libc linker issues

avravr-gcccompiler

So this seems to be a generic issue. "libc.a" is associate with some sort of incompatibility with floating point math and/or the correct library used.

I've added the "-lm" as suggested on the forums, but still unable to link/compile correctly?

Any other suggestions?


/opt/local/lib/gcc/avr/4.0.2/../../../../avr/lib/avr5/libc.a(cmpsf2.o):../../../libm/fplib/cmpsf2.S:58: multiple definition of __ltsf2'
/opt/local/lib/gcc/avr/4.0.2/avr5/libgcc.a(_lt_sf.o):/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_cross_avr-gcc/work/build/gcc/fp-bit.c:1272: first defined here
/opt/local/lib/gcc/avr/4.0.2/../../../../avr/lib/avr5/libc.a(floatsisf.o):../../../libm/fplib/floatsisf.S:44: multiple definition of
__floatsisf'
/opt/local/lib/gcc/avr/4.0.2/avr5/libgcc.a(_si_to_sf.o):/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_cross_avr-gcc/work/build/gcc/fp-bit.c:1334: first defined here
/opt/local/lib/gcc/avr/4.0.2/../../../../avr/lib/avr5/libc.a(modf.o):../../../libm/fplib/modf.S:88: relocation truncated to fit: R_AVR_13_PCREL against symbol `__subsf3' defined in .text section in /opt/local/lib/gcc/avr/4.0.2/avr5/libgcc.a(_addsub_sf.o)

Best Answer

A little explanation of what's really going on:

The -l argument order does not normally matter on computers since most libraries are dynamically loaded (.dll, .dylib or .so) and are truly linked only at program startup time.

OTOH on the AVR all libraries are static. When linking with static libraries the linker adds to the program only the functions he currently needs from the library. If you pass -lm on the command line before a file that needs a particular function you will get unresolved symbols errors.