" 'font' must be const " compile error

This post only serves to provide users with a resolution to the following error. The error occurs when a user downloads the Sparki “standalone” library for use with Linux operating systems, or the standard Arduino IDE on any OS, and attempts to compile a program.

Note: See roboalchemist’s reply to this post. His solution is much more efficient than the one I suggest here.

An example compilation error output:

Robot_Control/glcdfont.c
/usr/share/arduino/libraries/Robot_Control/glcdfont.c:9:23: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 static unsigned char  font[] PROGMEM = {

This happens due to the fact that newer versions of Arduino catch and hang on this during compilation.

To resolve the issue:

  1. Go to the Sparki library. In my case, it is in Documents\Arduino\Libraries.
  2. Open the “Sparki.cpp” file.
  3. Go to the line that contains the string " uint8_t font[] PROGMEM = { " It should be located above a 5x7 font table.
  4. Change " uint8_t " to " unsigned const int "
  5. Save the file.
  6. Restart the IDE

This solution worked for me. My programs upload without a hitch.

They did change a bunch of things for 1.6 (generally all better), but it did break some stuff.
But we have a new library that is v1.6 compatible! So use that instead. We just finished it an hour ago, so that’s why it wasn’t on the main site.
download.arcbotics.com/Sparki_Li … .6.6.1.zip

That said, instead of:
4) Change " uint8_t " to " unsigned const int "
try:
4) Change " uint8_t " to " const uint8_t "
This will save ~2x the memory (arduino ints are 16bit, vs 8bit uint8_t)

Thanks, I didn’t know that! And the new library works like a charm. :smiley: