question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile error: Adafruit GFX libraries won't find Wire.h / SPI.h

See original GitHub issue

Hi, whenever I start a new project in Platform IO for ESP8266 or ESP32 using Adafruit GFX Library I get a bunch of compile errors. The libraries using Wire.h / SPI.h won’t find them, but they’re clearly there, I can use them in my main code.

_Sorry if this is the wrong place to report this issue, but I really don’t know if this is an issue with Adafruit GFX, ESP8266/ESP32 Platform in Plaform IO, Platform IO VSCode IDE, Platform IO Core or VSCode… I don’t want to spam all repositories with this. Already opened an Issue here: https://github.com/adafruit/Adafruit-GFX-Library/issues/307_

main.cpp

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

void setup() {
  Wire.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
}

platformio.ini for ESP32:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = Adafruit GFX Library
Compiler output
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 1.12.1 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
LibraryManager: Installing id=13
Using cache: C:\Users\***\.platformio\.cache\cb\eb4a83205a6bf7664c071bda082bc1cb
Adafruit GFX Library @ 1.9.0 has been successfully installed!
Installing dependencies
Looking for Adafruit BusIO library in registry
Found: https://platformio.org/lib/show/6214/Adafruit BusIO
LibraryManager: Installing id=6214
Using cache: C:\Users\***\.platformio\.cache\87\51e35a894cbff55174e7997f44b7d387
Adafruit BusIO @ 1.3.2 has been successfully installed!
Found 28 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit GFX Library> 1.9.0
|   |-- <Adafruit BusIO> 1.3.2
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\lib1a3\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib1a3\Adafruit BusIO_ID6214\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib1a3\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp.o
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214/Adafruit_BusIO_Register.h:1:0,
                 from .pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp:1:
.pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

**************************************************************
* Looking for Wire.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Wire.h"
* Web  > https://platformio.org/lib/search?query=header:Wire.h
*
**************************************************************

compilation terminated.
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214\Adafruit_I2CDevice.cpp:1:0:
.pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

**************************************************************
* Looking for Wire.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Wire.h"
* Web  > https://platformio.org/lib/search?query=header:Wire.h
*
**************************************************************

compilation terminated.
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp:1:0:
.pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

compilation terminated.
Compiling .pio\build\esp32doit-devkit-v1\lib3d0\Adafruit GFX Library_ID13\Adafruit_GFX.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib3d0\Adafruit GFX Library_ID13\Adafruit_MonoOLED.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib3d0\Adafruit GFX Library_ID13\Adafruit_SPITFT.cpp.o
*** [.pio\build\esp32doit-devkit-v1\lib1a3\Adafruit BusIO_ID6214\Adafruit_I2CDevice.cpp.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib1a3\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp.o] Error 1
*** [.pio\build\esp32doit-devkit-v1\lib1a3\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp.o] Error 1
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit GFX Library_ID13\Adafruit_MonoOLED.h:30:0,
                 from .pio\libdeps\esp32doit-devkit-v1\Adafruit GFX Library_ID13\Adafruit_MonoOLED.cpp:20:
.pio\libdeps\esp32doit-devkit-v1\Adafruit BusIO_ID6214/Adafruit_I2CDevice.h:1:18: fatal error: Wire.h: No such file or directory

**************************************************************
* Looking for Wire.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Wire.h"
* Web  > https://platformio.org/lib/search?query=header:Wire.h
*
**************************************************************

compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib3d0\Adafruit GFX Library_ID13\Adafruit_MonoOLED.cpp.o] Error 1
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit GFX Library_ID13\Adafruit_SPITFT.cpp:36:0:
.pio\libdeps\esp32doit-devkit-v1\Adafruit GFX Library_ID13\Adafruit_SPITFT.h:26:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib3d0\Adafruit GFX Library_ID13\Adafruit_SPITFT.cpp.o] Error 1
================================================================================================== [FAILED] Took 5.62 seconds ==================================================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

platformio.ini for ESP8266:

[env:esp]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps = Adafruit GFX Library
Compiler output
Processing esp (platform: espressif8266; board: d1_mini; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 2.5.2 > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 3.20701.0 (2.7.1)
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.20800.0 (2.8.0)
 - toolchain-xtensa 2.40802.191122 (4.8.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 31 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit GFX Library> 1.9.0
|   |-- <Adafruit BusIO> 1.3.2
|   |   |-- <Wire> 1.0
|   |-- <Wire> 1.0
|-- <Wire> 1.0
Building in release mode
Compiling .pio\build\esp\src\main.cpp.o
Generating LD script .pio\build\esp\ld\local.eagle.app.v6.common.ld
Compiling .pio\build\esp\libbc2\Wire\Wire.cpp.o
Compiling .pio\build\esp\liba0c\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\esp\liba0c\Adafruit BusIO_ID6214\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\esp\liba0c\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp.o
Compiling .pio\build\esp\lib166\Adafruit GFX Library_ID13\Adafruit_GFX.cpp.o
Compiling .pio\build\esp\lib166\Adafruit GFX Library_ID13\Adafruit_MonoOLED.cpp.o
In file included from .pio\libdeps\esp\Adafruit BusIO_ID6214/Adafruit_BusIO_Register.h:2:0,
Compiling .pio\build\esp\lib166\Adafruit GFX Library_ID13\Adafruit_SPITFT.cpp.o
                 from .pio\libdeps\esp\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp:1:
.pio\libdeps\esp\Adafruit BusIO_ID6214/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
*** [.pio\build\esp\liba0c\Adafruit BusIO_ID6214\Adafruit_BusIO_Register.cpp.o] Error 1
In file included from .pio\libdeps\esp\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp:1:0:
.pio\libdeps\esp\Adafruit BusIO_ID6214/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
*** [.pio\build\esp\liba0c\Adafruit BusIO_ID6214\Adafruit_SPIDevice.cpp.o] Error 1
In file included from .pio\libdeps\esp\Adafruit GFX Library_ID13\Adafruit_MonoOLED.h:31:0,
                 from .pio\libdeps\esp\Adafruit GFX Library_ID13\Adafruit_MonoOLED.cpp:20:
.pio\libdeps\esp\Adafruit BusIO_ID6214/Adafruit_SPIDevice.h:1:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
*** [.pio\build\esp\lib166\Adafruit GFX Library_ID13\Adafruit_MonoOLED.cpp.o] Error 1
In file included from .pio\libdeps\esp\Adafruit GFX Library_ID13\Adafruit_SPITFT.cpp:36:0:
.pio\libdeps\esp\Adafruit GFX Library_ID13\Adafruit_SPITFT.h:26:17: fatal error: SPI.h: No such file or directory

*************************************************************
* Looking for SPI.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SPI.h"
* Web  > https://platformio.org/lib/search?query=header:SPI.h
*
*************************************************************

 #include <SPI.h>
                 ^
compilation terminated.
*** [.pio\build\esp\lib166\Adafruit GFX Library_ID13\Adafruit_SPITFT.cpp.o] Error 1
================================================================================================== [FAILED] Took 2.46 seconds ==================================================================================================
The terminal process terminated with exit code: 1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
valeroscommented, Jun 22, 2020

You don’t need to ignore them, you need to explicitly specify them as dependencies:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps =
    Adafruit GFX Library
    Wire
    SPI

Alternatively, you can add the following lines to your code so PlatformIO will detect dependencies automatically:

#include <Wire.h>
#include <SPI.h>
0reactions
valeroscommented, Jun 22, 2020

okay, so PlaformIO will detect that Wire/SPI etc is needed automatically if it is used in the main program, but not when used by libraries?

That’s true, that dependencies are probably hidden somewhere in the sources of external libraries, so the LDF is not able to detect them in default mode. You can control this behaviour by using other LDF modes https://docs.platformio.org/en/latest/librarymanager/ldf.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

not able to compile Platformio with GFX Library - Adafruit forums
The Compile error is: .platformio/lib/Adafruit STMPE610_ID377/Adafruit_STMPE610.cpp:32:10: fatal error: Wire.h: No such file or directory
Read more >
Unable to find wire.h while compiling adafruit library
So i'm trying to build libraries, my platform.ini is [env:seeed_xiao] platform = atmelsam board = seeed_xiao framework = arduino build_flags ...
Read more >
Fatal error: SPI.h - Programming Questions - Arduino Forum
I am using the following example code from adafruit for their TFTs. And while compiling, i get this error and cannot solve it....
Read more >
“.h: No such file or directory" - 2 Easy fixes to Arduino error
The easiest way is to go to Sketch > Include Library > Manage Libraries. The Arduino IDE will open up a dialogue box...
Read more >
All Libraries - Arduino Library List
MQTT library that supports the FONA, ESP8266, ESP32, Yun, and generic Arduino Client hardware. Adafruit MS8607, Arduino library for MS8607 sensors. Adafruit ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found