Problem compiling EmonGLCD scripts (e.g. SolarPV.ino) with Arduino 1.60

When I try to compile, I get the following error messages.  Is this a known problem and is there a workaround?

In file included from E:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,
                 from E:\Users\jlm_2\Documents\Arduino\libraries\jeelib/Ports.h:10,
                 from E:\Users\jlm_2\Documents\Arduino\libraries\jeelib/JeeLib.h:17,
                 from SolarPV.ino:44:
icons.ino:2:42: error: variable 'icon_heating_8x16' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
icons.ino:16:35: error: variable 'icon_home_13x12' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
icons.ino:21:36: error: variable 'icon_lines_12x12' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
icons.ino:26:42: error: variable 'icon_solar_12x12' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Error compiling.

I note that this problem came up in 2013 here; the solution was to change Arduino versions: http://openenergymonitor.org/emon/node/2564

Robert Wall's picture

Re: Problem compiling EmonGLCD scripts (e.g. SolarPV.ino) with Arduino 1.60

As far as I am aware, the icon data is not changed at all, therefore have you tried declaring the offending variables as "const" (in icons.ino)?

I am running Arduino 1.0.5 under Linux so I do not see the error when I compile that sketch.

[Edit:]
A Google search for "Arduino 1.6 compile error const read only" shows that you are not the first to see that error. It would appear that the newer version of the Arduino IDE enforces stricter rules for declarations. One of the suggestions was as above - add "const" to the declaration.

dBC's picture

Re: Problem compiling EmonGLCD scripts (e.g. SolarPV.ino) with Arduino 1.60

Yes, that change went into gcc 4.6 (https://gcc.gnu.org/gcc-4.6/changes.html)

Arduino 1.0.5 ships with avr-gcc (GCC) 4.3.2, and Arduino 1.0.6 ships with avr-gcc (GCC) 4.8.1

glyn.hudson's picture

Re: Problem compiling EmonGLCD scripts (e.g. SolarPV.ino) with Arduino 1.60

If you find the solution to this please make the changes to the github code to send us a pull request so we can get this fixes for everyone. Thanks 

jmessenger's picture

Re: Problem compiling EmonGLCD scripts (e.g. SolarPV.ino) with Arduino 1.60

I have added const to the declarations and this works.  I have submitted a pull request on github for this. 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.