Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › "undefined reference to `fabs'"

Page Index Toggle Pages: 1
"undefined reference to `fabs'" (Read 7224 times)
10/25/10 at 21:34:07

roypardi   Offline
Junior Member
I Love YaBB 2!
Boston USA

Posts: 57
**
 
Hi - I am getting the error: undefined reference to `fabs' in a current project. In trying to track down the issue, I broke the function out into a separate sketch - where it compiles fine (of course Wink.

Wondering if there is something else I can check/try. If I switch 'fabs()' to 'abs()' in my project it will compile - but I need floats.

Set up:
--Wiring 27 (downloaded last week)
--1st gen Wiring board
--Mac OSX 10.5.8

I was able to open + compile the sketch in the Arduino IDE and compile for the 1st gen Mega board (atmega 1280).

Don't know what else I can check or test - any tips?

--thanks!

Code:
static double arc_stepangle, arc_xc, arc_yc, arc_a0, arc_r, arc_phi;
static int16_t arc_step;

void setup()
{
}

void loop()
{
}

uint8_t arc_next(int32_t* x, int32_t* y) {
  uint8_t cont = 1;

  arc_step++;
  double alpha = arc_step*arc_stepangle;
  if (fabs(alpha) > fabs(arc_phi)) {
    alpha = arc_phi;
    cont = 0;
  }
  alpha += arc_a0;

  int32_t xd = arc_xc + arc_r*cos(alpha);
  int32_t yd = arc_yc + arc_r*sin(alpha);

  //userscale(xd, yd, x, y, &user_loc.x, &user_loc.y);

  return cont;//arc_step < arc_steps ? 1 : 0;
} 


 
IP Logged
 
Reply #1 - 10/25/10 at 22:14:10

roypardi   Offline
Junior Member
I Love YaBB 2!
Boston USA

Posts: 57
**
 
Ok - I am able to repro the compile error in the sketch below. If I comment out "Serial.print(cout);" then the sketch will compile. No idea what this might be about but it seems like it is not an error in my project code.

Fwiw - If I leave the print line in but just print some arbitrary val (e.g Serial.print(1)) then the sketch will compile.

Odd -

Code:
float testFloat = -1123.45;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  float cout;

  cout = fabs(testFloat);

  Serial.print(cout);

  delay(1000);
}
 

 
IP Logged
 
Reply #2 - 10/26/10 at 06:04:20

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
hi Roy, that's an interesting issue, I'll dig into it. The upper sketch works just fine, the lower one works as you mentioned. The funny thing is that it only affects fabs() no other commands in the math library work as expected. sin() etc...
« Last Edit: 10/26/10 at 07:47:48 by barragan »  
IP Logged
 
Reply #3 - 10/26/10 at 07:46:23

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Found it, it is an option for avr-gcc compiler, I've changed it in the distribution file directly so download it again wiring-0027.dmg and replace your current installation. Let me know.
 
IP Logged
 
Reply #4 - 10/26/10 at 14:50:24

roypardi   Offline
Junior Member
I Love YaBB 2!
Boston USA

Posts: 57
**
 
Yes, my project compiles now.

Thanks for the fix!!
 
IP Logged
 
Page Index Toggle Pages: 1