Mon 10 Jan 2011 10:23:12 AM UTC, original submission:
Hi,
the libm library will be not linked if the -lm command is added once! it must be added twice to get correct result!
main code:
#include "avr/io.h"
#include "math.h"
#define R1 10000
#define R0 10000
#define T0 298.15
#define B 3380
#define ZeroTemp 273.15
float get_temp(float Rth) {
float T = B / (log(Rth / (R0 * exp(-B / T0))));
return T - ZeroTemp;
}
int main(void) {
double x = 1234;
while (1) {
x = get_temp(x);
}
return 0;
}
Invoking: AVR Compiler
avr-gcc -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=attiny861 -DF_CPU=8000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o"main.o" "../main.c"
Invoking: AVR C++ Linker will not work correctly
avr-g++ -Wl,-Map,gpptest.map,--cref -mmcu=attiny861 -o"gpptest.elf" ./main.o -lm
Invoking: AVR C++ Linker work correctly
avr-g++ -Wl,-Map,gpptest.map,--cref -mmcu=attiny861 -o"gpptest.elf" ./main.o -lm -lm
See the problem to invoke the print size kommand!
avr-size --format=avr --mcu=attiny861 gpptest.elf
Best regards
Chris
|