Pages: [1]   Go Down
Author Topic: Build errors in math.h when building BlinkWithoutDelay example  (Read 7761 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just bought an arduino uno and installed the ide on my ubuntu 11. I have the arduino plugged into the laptop via usb and I loaded the BlinkWithoutDelay example and tried to upload it to the board.  I am getting these compiler errors.

In file included from /usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:44:0,
                 from /usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/delay.h:37,
                 from /home/mbell/Downloads/arduino-0023/hardware/arduino/cores/arduino/wiring_private.h:30,
                 from /home/mbell/Downloads/arduino-0023/hardware/arduino/cores/arduino/WInterrupts.c:34:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/math.h:426:15: error: expected identifier or ‘(’ before ‘double’
/usr/lib/gcc/avr/4.5.3/../../../avr/include/math.h:426:15: error: expected ‘)’ before ‘>=’ token


I feel fairly confident that neither Math.h or the example program are to blame, so I assume it is a configuration issue.  Any ideas what the issue might be?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5982
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know exactly where it is. That is in /usr/share/arduino/hardware/arduino/cores/arduino/wiring.h

There is a define that causes grief. I think it is around line 79 in that file you will find a "#define round" macro. You need to comment it out like this:
Code:
// #define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

It tries to replace the declaration of round in the math.h header file (line 426) and causes that compiler error.

Edit: Oops! I didn't know exactly where it is in YOUR install.  smiley-red
/home/mbell/Downloads/arduino-0023/hardware/arduino/cores/arduino/wiring.h

This is due to the upgrades I suggested back in August. The avr-gcc-1.7.1 delay.h file was missing the "#include <math.h>", so I would get a "no declaration for fabs and ceil" error. But when I added that include file, then I got the error you are getting now. The Ubuntu repository has both my bug fixes. That version of Arduino obviously does not.

« Last Edit: November 18, 2011, 08:37:35 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That did correct the build error. Thank you.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5982
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino crew was notified that this was happening, and offered a fix, which they have yet to implement. Read the comments here:
http://code.google.com/p/arduino/issues/detail?id=604&start=200
Logged

Pages: [1]   Go Up
Jump to: