linux gfx compile error glcdfont.c

by jfs10 on Wed Jan 02, 2013 7:25 pm

When trying to compile the examples for the 1.8TFT screen, I get the following error:

/usr/share/arduino/libraries/Adafruit_GFX/glcdfont.c:9:22: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

I am running Fedora 17 and arduino 1.0.1. I followed the links to download the latest libraries, still no success.

Does anyone have a solution to this problem?

Thanks
jfs10
 
Posts: 3
Joined: Wed Jan 02, 2013 6:57 pm

Re: linux gfx compile error glcdfont.c

by adafruit on Wed Jan 02, 2013 7:53 pm

can you try compiling the code on a windows/mac computer? it looks like the compiler is different for linux IDE?
User avatar
adafruit
 
Posts: 11638
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: linux gfx compile error glcdfont.c

by jfs10 on Thu Jan 03, 2013 7:19 am

Yes, it does work in Windows. I tried in version 1.0 then upgraded to version 1.0.3. Any chance of getting it to work in Linux again?

Thanks
jfs10
 
Posts: 3
Joined: Wed Jan 02, 2013 6:57 pm

Re: linux gfx compile error glcdfont.c

by adafruit on Thu Jan 03, 2013 11:28 am

the problem is if we fix it for linux, it breaks everything else - not sure of the solution at this time but we're aware of it and will try to find a solution
User avatar
adafruit
 
Posts: 11638
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: linux gfx compile error glcdfont.c

by jfs10 on Mon Jan 07, 2013 3:45 pm

Can you share the fix with me, or could you include both linux and windows files in the distribution and the linux user can rename the to a name that works and is consistent with the documentation. So, Adafruit_ST7735_linux.cpp would need to get renamed to Adafruit_ST7735.cpp for the linux user. Not ideal, but I would think doable.

Thanks
jfs10
 
Posts: 3
Joined: Wed Jan 02, 2013 6:57 pm

Re: linux gfx compile error glcdfont.c

by slibutti on Sun Jan 27, 2013 10:00 pm

I fixed glcdfont.c so it will compile on a linux based system running Arduino IDE by doing the following:

On line 9:

static unsigned char font[] PROGMEM = {

I added "const" to the line as follows:

const static unsigned char font[] PROGMEM = {

and now it compiles and runs.

S
slibutti
 
Posts: 5
Joined: Sat Dec 29, 2012 4:46 pm

Re: linux gfx compile error glcdfont.c

by jpg123 on Sat Feb 02, 2013 9:11 pm

The previous fix covered the compile prob with glcdfont.c, but it now has a host of other compile errors.
I'm also trying to get this to work on a linux IDE That is Raspberry Pi + Gertboard + Atmel 328

Is there a fix for the linux version problem yet in the pipeline ? As per the Orig post, a separate - linux - Raspberry Pi - Raspbian version fix would be good.

Many thanks
jpg123
 
Posts: 1
Joined: Sat Feb 02, 2013 8:55 pm

Re: linux gfx compile error glcdfont.c

by jsalassi on Mon May 13, 2013 11:08 pm

same problem here. After updating line 9 of gldfont.c to const static unsigned char font[] PROGMEM = { i get a host of the following compile errors:

/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:101:16: error: ‘prog_uchar’ does not name a type
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:159:12: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:161:11: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:196:13: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:198:16: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:205:24: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:206:14: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:213:19: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:215:11: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp: In member function ‘void Adafruit_ST7735::initB()’:
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:306:14: error: ‘Bcmd’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp: In member function ‘void Adafruit_ST7735::initR(uint8_t)’:
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:312:14: error: ‘Rcmd1’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:314:17: error: ‘Rcmd2green’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:319:17: error: ‘Rcmd2red’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:321:15: error: ‘Rcmd3’ was not declared in this scope
jsalassi
 
Posts: 6
Joined: Mon Apr 01, 2013 12:16 pm

Re: linux gfx compile error glcdfont.c

by jsalassi on Mon May 13, 2013 11:53 pm

OK so i'm not sure whats up with the libraries on github but here is how i resolved my problem. I credit Adafruit and the resources from the Adafruit forum for finding resolution to my problem.

1. Download libraries for my screen (sain smart 1.8" TFT LCD ST7735) from http://www.sainsmart.com/zen/documents/20-011-920/TFT18.rar

2. Unpack the content of zip file and copy into appropriately named "ST7735" libraries folder.

3. Restart Arduino IDE

3a. open up the file>examples>ST7735>graphicstest

3b. Save and give it a new name.

4. Try to compile and get error about glcdfont.c not a constant. Updated line 8 of glcdfont.c to be: const static unsigned char font[] PROGMEM = {

5. Try to compile again and get error about WProgram.h. Updated line 6 of ST7735.h to be: #include <Arduino.h>

6. Compiled this time with no issues.
jsalassi
 
Posts: 6
Joined: Mon Apr 01, 2013 12:16 pm

Re: linux gfx compile error glcdfont.c

by jsalassi on Wed May 15, 2013 3:03 pm

Any update on this issue?

/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:101:16: error: ‘prog_uchar’ does not name a type
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:159:12: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:161:11: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:196:13: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:198:16: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:205:24: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:206:14: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:213:19: error: expected unqualified-id before ‘,’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:215:11: error: expected constructor, destructor, or type conversion before ‘=’ token
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp: In member function ‘void Adafruit_ST7735::initB()’:
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:306:14: error: ‘Bcmd’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp: In member function ‘void Adafruit_ST7735::initR(uint8_t)’:
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:312:14: error: ‘Rcmd1’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:314:17: error: ‘Rcmd2green’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:319:17: error: ‘Rcmd2red’ was not declared in this scope
/home/jsalassi/sketchbook/libraries/Adafruit_ST7735/Adafruit_ST7735.cpp:321:15: error: ‘Rcmd3’ was not declared in this scope
jsalassi
 
Posts: 6
Joined: Mon Apr 01, 2013 12:16 pm

Re: linux gfx compile error glcdfont.c

by szarak on Sun May 19, 2013 10:54 am

Any update on this issue?


@jsalassi
I've came across same issues, but it occured that upgrading Arduino IDE fixed the issue.

Previously I used Arduino software from Ubuntu 12.10 repo, but I've manually downloaded Arduino 64bit version from official website. The code used to produce exactly the same errors like yours, now the same code produces shiny lorem ipsum text that I'm looking at right now ;)

Let me know if it worked for you as well!
szarak
 
Posts: 1
Joined: Sun May 19, 2013 10:50 am

Re: linux gfx compile error glcdfont.c

by jsalassi on Sun May 19, 2013 6:29 pm

ok ill try a new version of the IDE and let you know what happens.
jsalassi
 
Posts: 6
Joined: Mon Apr 01, 2013 12:16 pm

Re: linux gfx compile error glcdfont.c

by jsalassi on Wed May 22, 2013 12:54 pm

sweet thanks for the tip. I was able to compile using the 1.0.5 Arduino IDE release.
jsalassi
 
Posts: 6
Joined: Mon Apr 01, 2013 12:16 pm

Re: linux gfx compile error glcdfont.c

by MrMoose on Sun Jun 02, 2013 7:50 am

I came across quite a few such issues in other libraries as well.

Specifically constness is often treated in a not-so-good way that will sooner or later lead to such issues.
Like this:

void foo(char *n_text) {
println(n_text);
}

This is almost never right. Some older or windows compilers will allow you to do this:

foo("Hello world!")

Gcc (linux) will present a warning or in cases such as the one described, refuse to do this.Which is actually a good thing since allowing this is just wrong and broken.
Which is why it is deprecated and currently non-standard. Leading to issues such as this. To make sure everything is cool just remember to make everything const that can be const. Like this:

void foo(const char *n_text) {
println(n_text);
}

Or, in case it is a class method:

class A {
void foo(const char *n_text) const;
}

I had several such errors fixed in adafruit libs I have cloned here. Begging to question whether you accept patches or pull requests.

Cheers,
Moose
MrMoose
 
Posts: 8
Joined: Sat Jun 01, 2013 8:26 am

Re: linux gfx compile error glcdfont.c

by unexpectedly on Wed Jun 19, 2013 5:52 pm

Anything new? I prefer linux for my workstation, but looks like I get to turn on Windows now... :P Subscribed to see if I didn't just waste a few hours getting the Arduino working in linux. Wouldn't have bothered if I knew this. :(
unexpectedly
 
Posts: 42
Joined: Sun Nov 25, 2012 3:08 am