Go Down

Topic: Installing Arduino (023 and 1.0) on Linux -stupid errors- can't compile anything (Read 7852 times) previous topic - next topic

laurentp

Hi,
I am trying to install Arduino (probably 023 but same with 1.0) for MultiWii project on Linux.
I have COMPILED (not installed from packages):
- binutils 2.21.1
- gcc 4.6.2 with c and c++
- avr-libc 1.8.0

now I downloaded and unpacked Arduino package. OK,
but trying to build even "bareminimum" gives errors (023):

In file included from /usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/util/delay.h:44:0,
                 from /usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/avr/delay.h:37,
                 from /home/laurent/Desktop/Arduino_023/hardware/arduino/cores/arduino/wiring_private.h:30,
                 from /home/laurent/Desktop/Arduino_023/hardware/arduino/cores/arduino/WInterrupts.c:34:
/usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/math.h:426:15: error: expected identifier or '(' before 'double'
/usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/math.h:426:15: error: expected ')' before '>=' token

with 1.0 errors are different:

/home/laurent/Desktop/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
/home/laurent/Desktop/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp:44:9: error: 'prog_char' does not name a type
/home/laurent/Desktop/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp:47:23: error: 'p' was not declared in this scope

I CAN compile examples shipped with avr-libc.
everything for avr is installed in /usr/avr/*

Any ideas? [what is my stupid error?]

tmonteit

This is terrible.   I am having the exact same issue.    Examples should work out of the box without library issues.    Is there a fix for this?

SurferTim

I know this bug. This is caused by a "#define round" macro that was in wiring.h in V0022.
Quote
In file included from /usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/util/delay.h:44:0,
                 from /usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/avr/delay.h:37,
                 from /home/laurent/Desktop/Arduino_023/hardware/arduino/cores/arduino/wiring_private.h:30,
                 from /home/laurent/Desktop/Arduino_023/hardware/arduino/cores/arduino/WInterrupts.c:34:
/usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/math.h:426:15: error: expected identifier or '(' before 'double'
/usr/avr/lib/gcc/avr/4.6.2/../../../../avr/include/math.h:426:15: error: expected ')' before '>=' token

Look in
/home/laurent/Desktop/Arduino_023/hardware/arduino/cores/arduino/wiring_private.h:30,
and check for a "#define round" macro and comment it out. It is trying to replace the round function in math.h at line 426.


laurentp

Great, it worked (at least for "bareminimum")...
EDIT: MultiWii compiles too,thanks.

With a small correction: i have found that macro in wiring.h not in wiring_private.h.

SurferTim

With a small correction: i have found that macro in wiring.h not in wiring_private.h.

Oops. My bad. I thought wiring.h disappeared in V0023, but I guess it disappeared in V1.0.
I skipped V0023 altogether. I'm using v0022 and testing v1.0 now. :)

That bug was due to a change in the avr-libc delay function. Starting with avr-libc v1.7.1 and later (yours is 1.8.0), delay.h requires "#include <math.h>" to correct a timing error in the delay() functions. The "#define round" was for earlier versions of avr-libc to apparently correct an error in those versions.

I haven't ran into that print error in V1.0 (yet).

Jarod

I've got these issues too, Arduino 0023 works after the modification SurferTim mentioned in wiring.h

However 1.0 always gets the same errors about Print.cpp:

Code: [Select]
/home/thomas/arduino/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
/home/thomas/arduino/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp:44:9: error: 'prog_char' does not name a type
/home/thomas/arduino/arduino-1.0/hardware/arduino/cores/arduino/Print.cpp:47:23: error: 'p' was not declared in this scope


even the latest sources from git do the same thing. heres some info on my machine in case it might help:

amd64 gentoo with kernel 3.0.3

binutils-2.22-r1
gcc-4.5.3-r2
avr-libc-1.8.0

I can provide loads more info if necessary.



SurferTim

I think it is due to a deprecated typedef in avr-libc v1.8.0.
Quote
/**
  \ingroup avr_pgmspace
  \typedef prog_char
  \note DEPRECATED

  This typedef is now deprecated because the usage of the __progmem__
  attribute on a type is not supported in GCC. However, the use of the
  __progmem__ attribute on a variable declaration is supported, and this is
  now the recommended usage.

  The typedef is only visible if the macro __PROG_TYPES_COMPAT__
  has been defined before including <avr/pgmspace.h> (either by a
  #define directive, or by a -D compiler option.)

  Type of a "char" object located in flash ROM.
*/
typedef char PROGMEM prog_char;


A couple things I might try in Print.cpp:
1) define that macro
or
2) change the data type from "prog_char" to "char PROGMEM" in print(const _FlashStringHelper*).

Edit: This variable declaration works with V1.0 and avr-libc v1.7.1 in Print.cpp.
Code: [Select]
/* Old code
size_t Print::print(const __FlashStringHelper *ifsh)
{
  const prog_char *p = (const prog_char *)ifsh;
  size_t n = 0;
  while (1) {
    unsigned char c = pgm_read_byte(p++);
    if (c == 0) break;
    n += write(c);
  }
  return n;
}
*/

// New code
size_t Print::print(const __FlashStringHelper *ifsh)
{
  const char PROGMEM *p = (const char PROGMEM *)ifsh;
  size_t n = 0;
  while (1) {
    unsigned char c = pgm_read_byte(p++);
    if (c == 0) break;
    n += write(c);
  }
  return n;
}


czarny


2) change the data type from "prog_char" to "char PROGMEM" in print(const _FlashStringHelper*).

I can confirm that your patch has fixed the problem here on Arduino 1.0 and avr-libc-1.8.0
Thank you!

SurferTim



2) change the data type from "prog_char" to "char PROGMEM" in print(const _FlashStringHelper*).

I can confirm that your patch has fixed the problem here on Arduino 1.0 and avr-libc-1.8.0
Thank you!

You are welcome.

The bug has been reported to the Arduino crew. Here is the report if you want to follow it.
http://code.google.com/p/arduino/issues/detail?id=795

Go Up