bugAVR C Runtime Library - Bugs: bug #29458, log10 compile errors

 
 

bug #29458: log10 compile errors

Submitted by:  Simco - R.Fischer <simconl>
Submitted on:  Wed 07 Apr 2010 06:16:41 AM UTC  
 
Category:  Library Severity:  3 - Normal
Priority:  5 - Normal Item Group:  libc code
Status:  Duplicate Assigned to:  None
Percent Complete:  0% Open/Closed:  Closed
Release:  Unknown Fixed Release:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 28 Mar 2012 09:35:21 PM UTC, comment #5: 

> This is essentially just another incarnation of
> bug #3485.


I'd rather say it's a duplicate of bug #33698.

-lm might mask the very problem in most situations, but the root problem is still there: explicit use of cross-module RCALL/RJMP.

Georg-Johann Lay <gjlayde>
Wed 07 Apr 2010 08:33:01 AM UTC, comment #4: 

This is essentially just another incarnation of bug #3485.

Joerg Wunsch <joerg_wunsch>
Project Administrator
Wed 07 Apr 2010 07:09:37 AM UTC, comment #3: 

Anitha solved my problem:

  I think you haven't included libm.a. Please revisit you
  project configuration. This has built fine for me when I
  made the change.

  http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_libm

  Anitha

And yes, this seems to work. Because I didn't get the 'undefined reference' error, I didn't found this solution is the FAQ.

Thanks!

Regards,
Robert.

Simco - R.Fischer <simconl>
Wed 07 Apr 2010 07:04:33 AM UTC, comment #2: 

Hello Joerg,

It seems a link error. The attached Studio4 screendump show the folowing message:

  rm -rf FloatTest.o  FloatTest.elf dep/* FloatTest.hex
      FloatTest.eep FloatTest.lss FloatTest.map
  Build succeeded with 0 Warnings...
  avr-gcc  -mmcu=atxmega128a1 -Wall -gdwarf-2 -Os -std=gnu99
      -funsigned-char -funsigned-bitfields -fpack-struct
      -fshort-enums -MD -MP -MT FloatTest.o -MF
      dep/FloatTest.o.d  -c  ../FloatTest.c
  avr-gcc -mmcu=atxmega128a1 -Wl,-Map=FloatTest.map
      FloatTest.o     -o FloatTest.elf
  c:/program files/winavr-
       20100110/bin/../lib/gcc/avr/4.3.3/../../../../
       avr/lib/avrxmega7\libc.a(floatsisf.o): In function
       `__floatunsisf':
  (.text.avr-libc.fplib+0x0): multiple definition of
       `__floatunsisf'
  c:/program files/winavr-
       20100110/bin/../lib/gcc/avr/4.3.3/avrxmega7\libgcc.a
       (_usi_to_sf.o):c:\avrdev\gcc\build-avr\avr\avrxmega7
       \libgcc/../../.././gcc/fp-bit.c:1391: first defined
       here
  make: *** [FloatTest.elf] Error 1
  Build failed with 1 errors and 0 warnings...

I compile with Studio4, I do not know how to add the -ml option.

Regards,
Robert.

Simco - R.Fischer <simconl>
Wed 07 Apr 2010 06:52:10 AM UTC, comment #1: 

Which errors do you get?  Just claiming "compile/link errors"
is way too generic to judge about anything.

Also, did you include -lm to the end of the linker commandline?
(It's always best to quote the complete commandline used to
compile your test program.)

Please answer these questions until 2010-04-10 so we can proceed.

Joerg Wunsch <joerg_wunsch>
Project Administrator
Wed 07 Apr 2010 06:16:41 AM UTC, original submission:  

Hello,

Using the folowing code results to compile/link errors:

#include <math.h>

/***************************************************************
Project:  SHTxx
***************************************************************/
typedef union
{
  unsigned int  i;
  float         f;
} value;

//--------------------------------------------------------------
// calculates dew point
// input:humidity [%RH], temperature []
// output:  dew point
//--------------------------------------------------------------
float calc_dewpoint(float h, float t)
{
  float  logEx;
  float  dew_point;

  /**/
  // Original code (ERROR!!!):
  logEx     = 0.66077 + 7.5 * t / (237.3 + t) + (log10(h) - 2);
  dew_point = (logEx - 0.66077) * 237.3 /
               (0.66077 + 7.5 - logEx);
  /**/

  /*
  // Modified code (just for the test):
  logEx     = 0.66077 + 7.5 * t / (237.3 + t) + (1.0 - 2);
  dew_point = (logEx - 0.66077) * 237.3 /
               (0.66077 + 7.5 - logEx);
  */

  return dew_point;
}

//--------------------------------------------------------------
// sample program that shows how to use SHT11 functions
//--------------------------------------------------------------
int main(void)
{
  value  humi_val;
  value  temp_val;
  float  dew_point;

  while (1)
  {
    //converts integer to float
    humi_val.f = (float)humi_val.i;
    temp_val.f = (float)temp_val.i;

    //calculate dew point
    dew_point = calc_dewpoint(humi_val.f,
                              temp_val.f);
  }

  return 0;
}

I'm using the WinAVR20100110 compiler, but the WinAVR20090313 has the same problem. I also use Studio4 4.18 SP2 build 700. The used micro is a ATXmega128A1.

See function calc_dewpoint(). When I compile with the original code, it results in an compile error, so I modified the code and replaced the log10(h) code into 1.0. Now it is compiled without any errors.

Hope this problem will be fixed soon.

Regards,
Robert.

Simco - R.Fischer <simconl>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #20145:  WinAvrBug.JPG added by simconl (215KiB - image/pjpeg)
file #20144:  FloatTest_20100406c.zip added by simconl (10KiB - application/x-zip-compressed)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gjlayde (Posted a comment)
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by simconl (Submitted the item)
  • -email is unavailable- added by simconl
  •  

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-04-07 joerg_wunsch StatusNeed Info => Duplicate
        Open/ClosedOpen => Closed
    2010-04-07 joerg_wunsch StatusNone => Need Info
    2010-04-07 simconl Attached File- => Added FloatTest_20100406c.zip, #20144
        Attached File- => Added WinAvrBug.JPG, #20145
        Carbon-Copy- => Added simconl

    Back to the top


    Powered by Savane 3.5