log10( )

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi Everyone,

i'm getting an error message when i try to compile and i am not sure why this error is popping up

Build started 22.12.2011 at 12:41:45
avr-gcc  -mmcu=atmega64 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT monitor2.o -MF dep/monitor2.o.d  -c  ../monitor2.c
avr-gcc -mmcu=atmega64 -Wl,-Map=mon2.map monitor2.o     -o mon2.elf
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr5\libc.a(floatsisf.o): In function `__floatunsisf':
(.text.avr-libc.fplib+0x0): multiple definition of `__floatunsisf'
c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr5\libgcc.a(_usi_to_sf.o):c:\avrdev\gcc\build-avr\avr\avr5\libgcc/../../.././gcc/fp-bit.c:1391: first defined here
make: *** [mon2.elf] Error 1
Build failed with 1 errors and 0 warnings...

I isolated the problem to this function in where i call 'log10( )' -

// ADC4 - Battery Temperature
int NTCthermistor(void)
{	
	int temp = 0;
	double VtempC=0; 
	double R_temp=0;// Sensor resistance - Ambient temp
	unsigned int ADC_t = 0;
	ADC_t = ReadADC(4);						
	VtempC = ADC_t* 4.88281;	// 5000[mV]/1024=4.88281
	R_temp = 1.0 * VtempC / (5000.0 - VtempC);
	temp = 71.938 - 47.487*log10(R_temp);	
	
	return temp;			// [Celsius]
}

i also use log10() in another function that seems to have the same problem. I am including the following libraries

#include 
#include 
#include 
#include  
#include 
#include 
#include 
#include 
#include 					
#include 

any ideas?
Thank you!

- Eric

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have probably not linked in

Quote:
libm.a &
libprintf_flt.a

Edit.
Added graphic to show linker options with AVR Studio

Attachment(s): 

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

Last Edited: Thu. Dec 22, 2011 - 08:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You have probably not linked in
Quote:
libm.a &
libprintf_flt.a

could you expand on this? i don't know what you mean. Thank you,
Eric

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That build output *looks* like you are using AS4 so under Project-configuration options go to the "libraries" tab and make sure that libm.a is copied from the left pane to the right one.

The upshot of all this is that the build command should become:

avr-gcc -mmcu=atmega64 -Wl,-Map=mon2.map monitor2.o     -o mon2.elf -lm

It's a very subtle looking change but that "-lm" added to the linker command line says take "m" add "lib" to the front and ".a" to the end then link against that (libm.a). It has duplicate copies of functions such as __floatunsisf inside which over-ride the weak links in the standard lib.

The standard lib is some crap C code written for i386 built into the C compiler that is used until something better turns up. The libm.a is about 1K of perfectly crafted AVR asm code that replaces that 3K of crap from the standard lib with some maths routines you really want.

(it was about 6 years ago that I told Atmel they should (like Mfile) be linking with libm.a by default. Still nothing!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IIRC I learned that tip from you many years ago Cliff! I have edited my original response to include setup graphic

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks Cliff and LDEVRIES, problem solved!

- Eric