Compilation oddities

I was trying to get the TFT panel to work today. I came across this post (A 1.8 inch TFT color display (HY-1.8 SPI) and an Arduino | simtronyx – Das Elektronik Blog ) which worked for me.
I used pio’s library manager to get the libraries:

Library Storage: /home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps
Adafruit GFX Library
====================
#ID: 13
Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.

Version: 1.1.9
Keywords: display
Compatible frameworks: arduino
Compatible platforms: atmelavr, atmelsam, espressif8266, intel_arc32, microchippic32, nordicnrf51, teensy, timsp430
Authors: Adafruit

Adafruit ST7735 Library
=======================
#ID: 12
A library for the Adafruit 1.8"" SPI display

Version: 1.0.4
Keywords: spi, tft, display, graphics
Compatible frameworks: arduino
Compatible platforms: atmelavr, atmelsam, espressif8266, intel_arc32, microchippic32, nordicnrf51, teensy, timsp430
Authors: Adafruit Industries

Adafruit_GFX
============
#ID: 188
A derived version of the BSD licensed Adafrut GFX library for the SSD1306 controller for an OLED 128x32 or 128x64 display using SPI or I2C.

Version: 7fb1d4d352
Keywords: spi, oled, i2c, display, ssd1306
Compatible frameworks: mbed
Compatible platforms: freescalekinetis, teensy, nxplpc, nordicnrf51, ststm32
Authors: Neal Horman

But when i copy/paste(d) the code, i saw the error by linter “Error GCC Adafruit_ST7735.h: No such file or directory”. At the same time code compiles and uploads fine.
I also ran :

locate Adafruit_ST7735.h
/home/az/.platformio/packages/framework-arduinoavr/libraries/TFT/src/utility/Adafruit_ST7735.h

Yes, i understand that i probably should have put libraries into a local project’s “lib” directory, but still.
Any ideas?

Probably because linter is looking for that file under /lib/TFT/src
And the library itself is located under /lib/TFT/src/utility

Can you just create a file “.clang_complete” in the project root directory and add "-I//home/az/.platformio/packages/framework-arduinoavr/libraries/TFT/src/utility/"

to the .clang_complete
It should make the error go away and also scan the header and show the autocomplete suggestions.

Could you provide a full output of pio run -v command?

Ivan,
platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino

And the run:

[az@toshiba LCD]$ pwd
/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD
[az@toshiba LCD]$ pio run -v > run.log
Framework incompatible library /home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps/Adafruit_GFX_ID188
More details about "Library Compatibility Mode": http://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode

and the run.log is :

[Tue May  2 18:43:48 2017] Processing uno (platform: atmelavr; board: uno; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------
Collected 30 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <Adafruit ST7735 Library> v1.0.4 (/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps/Adafruit ST7735 Library_ID12)
|   |-- <Adafruit GFX Library> v1.1.9 (/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps/Adafruit GFX Library_ID13)
|   |-- <SPI> v1.0 (/home/az/.platformio/packages/framework-arduinoavr/libraries/SPI)
|-- <SPI> v1.0 (/home/az/.platformio/packages/framework-arduinoavr/libraries/SPI)
avr-size --mcu=atmega328p -C -d .pioenvs/uno/firmware.elf
AVR Memory Usage
----------------
Device: atmega328p

Program:    9214 bytes (28.1% Full)
(.text + .data + .bootloader)

Data:        125 bytes (6.1% Full)
(.data + .bss + .noinit)

In the source file i have :

// #include <Adafruit_GFX.h> // Adafruit Grafik-Bibliothek
#include <Adafruit_ST7735.h> // Adafruit ST7735-Bibliothek
#include <SPI.h>
 <skip>

Removing 188 lib ( “Adafruit_GFX” ) resolved the problem all together.
and the build looks like this :


[Tue May  2 18:56:08 2017] Processing uno (platform: atmelavr; board: uno; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 30 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <Adafruit ST7735 Library> v1.0.4
|   |-- <Adafruit GFX Library> v1.1.9
|   |-- <SPI> v1.0
|-- <SPI> v1.0
Compiling .pioenvs/uno/src/lcd.o
Archiving .pioenvs/uno/libFrameworkArduinoVariant.a

The only question i have is - how do i read that little dependency graph? I don’t have an import for SPI anywhere in my code. So why there is a direct(?) dep on SPI? just curious.
Thank you

Doesn’t look like i’m getting a break these days…
with another project:

#include "Adafruit_LiquidCrystal.h"
#include <Arduino.h>
<skip>

the error is “no such file” on LiquidCrystal.h

pio lib search -i Adafruit_LiquidCrystal.h
Found 1 libraries:

Adafruit LiquidCrystal
======================
#ID: 855
Fork of LiquidCrystal HD44780-compatible LCD driver library, now with support for ATtiny85
<skip>

[az@toshiba LCD]$ pio lib list
Library Storage: /home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps
Adafruit GFX Library
====================
#ID: 13
<skip>
Adafruit LiquidCrystal
======================
#ID: 855
Fork of LiquidCrystal HD44780-compatible LCD driver library, now with support for ATtiny85.
<skip>
Adafruit ST7735 Library
=======================
#ID: 12
A library for the Adafruit 1.8" SPI display
<skip>
[az@toshiba LCD]$ cd .piolibdeps/
[az@toshiba .piolibdeps]$ ls
'Adafruit GFX Library_ID13'  'Adafruit LiquidCrystal_ID855'  'Adafruit ST7735 Library_ID12'

[az@toshiba .piolibdeps]$ ls -l Adafruit\ LiquidCrystal_ID855/
total 36
-rw-rw-r--  1 az az 12133 Sep  4  2016 Adafruit_LiquidCrystal.cpp
-rw-rw-r--  1 az az  3278 Sep  4  2016 Adafruit_LiquidCrystal.h
drwxrwxr-x 13 az az  4096 May  2 20:11 examples
-rw-rw-r--  1 az az   840 Sep  4  2016 keywords.txt
-rw-rw-r--  1 az az   381 Sep  4  2016 library.properties
-rw-rw-r--  1 az az  2007 Sep  4  2016 README.md
drwxrwxr-x  2 az az  4096 May  2 20:11 utility

and :

[az@toshiba LCD]$ pwd
/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD
[az@toshiba LCD]$
[az@toshiba LCD]$ pio run -v
[Tue May  2 22:42:48 2017] Processing uno (platform: atmelavr; board: uno; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------
Collected 29 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <Adafruit LiquidCrystal> v1.0.0 (/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps/Adafruit LiquidCrystal_ID855)
avr-g++ -o .pioenvs/uno/src/i2clcd.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega328p -DF_CPU=16000000L -DPLATFORMIO=30400 -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO -DARDUINO=10617 -I/home/az/.platformio/packages/framework-arduinoavr/cores/arduino -I/home/az/.platformio/packages/framework-arduinoavr/variants/standard "-I.piolibdeps/Adafruit LiquidCrystal_ID855" "-I.piolibdeps/Adafruit LiquidCrystal_ID855/utility" -Isrc src/i2clcd.cpp
avr-g++ -o ".pioenvs/uno/lib/Adafruit LiquidCrystal_ID855/utility/Adafruit_MCP23008.o" -c -fno-exceptions -fno-threadsafe-statics
 -fpermissive -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega328p -DF_CPU=16000000L -DPLATFORMIO
=30400 -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO -DARDUINO=10617 -I/home/az/.platformio/packages/framework-arduinoavr/cores/arduino -I
/home/az/.platformio/packages/framework-arduinoavr/variants/standard "-I.piolibdeps/Adafruit LiquidCrystal_ID855" "-I.piolibdeps/
Adafruit LiquidCrystal_ID855/utility" ".piolibdeps/Adafruit LiquidCrystal_ID855/utility/Adafruit_MCP23008.cpp"
.piolibdeps/Adafruit LiquidCrystal_ID855/utility/Adafruit_MCP23008.cpp:19:18: fatal error: Wire.h: No such file or directory
#include <Wire.h>
^
compilation terminated.
*** [.pioenvs/uno/lib/Adafruit LiquidCrystal_ID855/utility/Adafruit_MCP23008.o] Error 1
=================================================== [ERROR] Took 1.90 seconds ===================================================

the examples all include an explicit call to “wire.h” (Adafruit LiquidCrystal_ID855/examples/Blink/Blink.pde).
Once i added Wire.h the code compiles, BUT:
1 . even though i stick #include Wire,h before all includes, after i hit a “save file” it (#include) moved to be last out of 3 includes:

#include <Wire.h>
#include <Adafruit_LiquidCrystal.h>
#include <Arduino.h>

to after “save”

#include <Adafruit_LiquidCrystal.h>
#include <Arduino.h>
#include <Wire.h>

The linter’s error is still there, but it compiles now:

find ~ -name Wire.h
/home/az/.platformio/packages/framework-arduinoavr/libraries/__cores__/panstamp/Wire/Wire.h
/home/az/.platformio/packages/framework-arduinoavr/libraries/Wire/src/Wire.h
[az@toshiba LCD]$ pio run -v
[Tue May  2 23:20:26 2017] Processing uno (platform: atmelavr; board: uno; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------
Collected 30 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <Adafruit LiquidCrystal> v1.0.0 (/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/.piolibdeps/Adafruit LiquidCrystal_ID855)
|   |-- <Wire> v1.0 (/home/az/.platformio/packages/framework-arduinoavr/libraries/Wire)
|-- <Wire> v1.0 (/home/az/.platformio/packages/framework-arduinoavr/libraries/Wire)
avr-g++ -o .pioenvs/uno/src/i2clcd.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -g -Os -Wall -ffunction
-sections -fdata-sections -flto -mmcu=atmega328p -DF_CPU=16000000L -DPLATFORMIO=30400 -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO -DARDU
INO=10617 -I/home/az/.platformio/packages/framework-arduinoavr/cores/arduino -I/home/az/.platformio/packages/framework-arduinoavr
<skip>

and the libs graph does make sense to me. But why did i have to manually include “wire.h” to my main program? the lib’s cpp file had it in “include”…

The apm :

Community Packages (15) /home/az/.atom/packages
├── atom-beautify@0.29.23
├── autocomplete-clang@0.11.3
├── build@0.67.0
├── busy@0.7.0
├── file-icons@2.1.4
├── git-control@0.9.0
├── intentions@1.1.2
├── language-ini@1.19.0
├── linter@2.1.4
├── linter-gcc@0.7.1
├── linter-ui-default@1.2.3
├── minimap@4.28.1
├── platformio-ide@2.0.0-beta.2
├── platformio-ide-terminal@2.5.0
└── tool-bar@1.1.0

i’m going over other pieces of code i have and the linter is consistently unhappy ( blah.h doesn’t exist, but code compiles) with all non-standard libraries.
at the same time if i put a library into “lib” directory - linter is happy as expected.

@krishna_chaitanya:
thank you, but i already have the clang_complete in the root f the project… Do i need to manually update it every time i add/remove the library?
current file:

-I/home/az/.platformio/packages/framework-arduinoavr/cores/arduino
-I/home/az/.platformio/packages/framework-arduinoavr/variants/standard
-I/home/az/Dropbox/work/Arduino/Sketches/Sockets/LCD/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Adafruit_CircuitPlayground
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Adafruit_CircuitPlayground/utility
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Bridge/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/EEPROM/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Esplora/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Ethernet/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Firmata
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Firmata/utility
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/GSM/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/HID/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Keyboard/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/LiquidCrystal/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Mouse/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/RobotIRremote/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Robot_Control/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Robot_Motor/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/SD/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/SPI/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/SPI1/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Scheduler/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Servo/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/SoftwareSerial/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/SpacebrewYun/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Stepper/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/TFT/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Temboo/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/USBHost/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/WiFi/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Wire/src
-I/home/az/.platformio/packages/framework-arduinoavr/libraries/Wire1/src
-I/home/az/.platformio/packages/toolchain-atmelavr/avr/include
-I/home/az/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/4.9.2/include
-I/home/az/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/4.9.2/include-fixed
-I/home/az/.platformio/packages/tool-unity
-DF_CPU=16000000L
-DPLATFORMIO=30400
-DARDUINO_ARCH_AVR
-DARDUINO_AVR_UNO
-DARDUINO=10617
-D__AVR_ATmega328P__