A weird linker error

Oct. 29, 2011, 4:41 p.m.

So lately I've been having trouble with linking my avr (arduino) project in Eclipse, after I've added math.h to my source code. avr-g++ said:

relocation truncated to fit: R_AVR_13_PCREL

The solution:

Under your Project properties / C/C++ Build / Settings / AVR C++ Linker change the command line pattern to this:

${COMMAND} -lc -lm ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} -lc

It seems, the order in which the libc and libm are called in this command line, has an influence.

And don't forget to put the include of "math.h" before every occurrence of "wiring.h" or "WProgram.h". Otherwise you'll get compiler errors :-)

tags: arduino avr error linker

read more