Adafruit GFX lib will not build any more (PIO 5)


I today upgraded to PlatformIO 5 and now the Adafruit GFX lib will not compile any more, due to a missing file:

Compiling .pio\build\az-delivery-devkit-v4\libcda\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
In file included from .pio\libdeps\az-delivery-devkit-v4\Adafruit GFX Library\Adafruit_GrayOLED.cpp:20:0:
.pio\libdeps\az-delivery-devkit-v4\Adafruit GFX Library\Adafruit_GrayOLED.h:30:32: fatal error: Adafruit_I2CDevice.h: No such file or directory

* Looking for Adafruit_I2CDevice.h dependency? Check our library registry!
* CLI  > platformio lib search "header:Adafruit_I2CDevice.h"
* Web  >

compilation terminated.
*** [.pio\build\az-delivery-devkit-v4\libcda\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o] Error 1

The platformio lib search points to Adafruit BusIO - but that is installed, with the missing file:
Adafruit BusIO

What am I to do to solve this?

I manually added “Adafruit BusIO” to the lib_deps section in platformio.ini - that seems to solve it temporarily, but why did it work before without that? And should not the dependency be resolved automatically, since the lib was there already without me doing anything about it?

If you clear the .pio\libdeps folder again and add

lib_ldf_mode = chain+

(docs) in the platformio.ini, does the dependency graph show the library then?

I did so and it built okay. But in .pio\libdeps now only the two lib_deps libraries pulled from Github are to be found any more. Compilation took obviously those from .pio\build now. Will that tell us anything? The Adafruit BusIO dependency also was still in platformio.ini…

So in the next attempt I deleted everything in .pio\build as well, and removed the Adafruit BusIO line from platformio.ini I had manually added and voilà: there the error was again.

The lib_ldf_mode = chain+ line seems not to have changed anything in the output, BTW.

Dependency Graph
|-- <SimpleButton>
|   |-- <Wire> 1.0.1
|-- <Adafruit GFX Library> 1.10.0
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <Adafruit SSD1306> 2.3.1
|   |-- <Adafruit GFX Library> 1.10.0
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <Ticker> 3.1.5
|-- <ArduinoOTE> 1.0
|   |-- <Update> 1.0
|   |-- <ESPmDNS> 1.0
|   |   |-- <WiFi> 1.0
|   |-- <Ethernet> 2.0.0+sha.c9399a9
|   |   |-- <SPI> 1.0
|-- <Ethernet> 2.0.0+sha.c9399a9
|   |-- <SPI> 1.0
|-- <esp32ModbusRTU> 0.0.2+sha.d9c0758
|-- <Update> 1.0
|-- <Wire> 1.0.1
|-- <FS> 1.0
|-- <SPIFFS> 1.0
|   |-- <FS> 1.0
|-- <TheBase>
|-- <SPI> 1.0

I’ve the same problem with platformio ci:


#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>

Adafruit_SSD1306 display(-1);

Build script

platformio lib --global install "adafruit/Adafruit GFX Library"
platformio lib --global install "adafruit/Adafruit SSD1306"
platformio lib --global install "adafruit/Adafruit BusIO"

platformio ci --lib="." --board uno examples/Test/Test.ino


Starting auto-build script...
Installing library dependencies
Library Storage: /home/erwin/.platformio/lib
Library Manager: Low-Power @ 1.6.0 is already installed
Library Storage: /home/erwin/.platformio/lib
Library Manager: SD @ 1.2.4+sha.85dbcca is already installed
Library Storage: /home/erwin/.platformio/lib
Library Manager: Adafruit GFX Library @ 1.10.1 is already installed
Library Storage: /home/erwin/.platformio/lib
Library Manager: Adafruit SSD1306 @ 2.4.0 is already installed
Library Storage: /home/erwin/.platformio/lib
Library Manager: Adafruit BusIO @ 1.5.0 is already installed
Building examples...
The next files/directories have been created in /tmp/tmp5_iq909c
include - Put project header files here
lib - Put here project specific (private) libraries
src - Put project source files here
platformio.ini - Project Configuration File

Project has been successfully initialized! Useful commands:
`pio run` - process/build project from the current directory
`pio run --target upload` or `pio run -t upload` - upload firmware to a target
`pio run --target clean` - clean project (remove compiled files)
`pio run --help` - additional information
Processing uno (platform: atmelavr; board: uno; framework: arduino)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Atmel AVR (2.2.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)
 - framework-arduino-avr 5.0.0 
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
Converting Test.ino
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit GFX Library> 1.10.1
|   |-- <Wire> 1.0
|   |-- <SPI> 1.0
|-- <Adafruit SSD1306> 2.4.0
|   |-- <Adafruit GFX Library> 1.10.1
|   |   |-- <Wire> 1.0
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0
|-- <Wire> 1.0
Building in release mode
Compiling .pio/build/uno/src/Test.ino.cpp.o
Compiling .pio/build/uno/lib9db/Wire/Wire.cpp.o
Compiling .pio/build/uno/lib9db/Wire/utility/twi.c.o
Compiling .pio/build/uno/lib559/SPI/SPI.cpp.o
Compiling .pio/build/uno/lib33c/Adafruit GFX Library/Adafruit_GFX.cpp.o
Compiling .pio/build/uno/lib33c/Adafruit GFX Library/Adafruit_GrayOLED.cpp.o
Compiling .pio/build/uno/lib33c/Adafruit GFX Library/Adafruit_SPITFT.cpp.o
Compiling .pio/build/uno/lib33c/Adafruit GFX Library/glcdfont.c.o
In file included from /home/erwin/.platformio/lib/Adafruit GFX Library/Adafruit_GrayOLED.cpp:20:0:
/home/erwin/.platformio/lib/Adafruit GFX Library/Adafruit_GrayOLED.h:30:32: fatal error: Adafruit_I2CDevice.h: No such file or directory

* Looking for Adafruit_I2CDevice.h dependency? Check our library registry!
* CLI  > platformio lib search "header:Adafruit_I2CDevice.h"
* Web  >

Note: The build script installs Adafruit BusIO correctly and is located in /home/erwin/.platformio/lib/Adafruit BusIO/Adafruit_I2CDevice.h, but could not be found.

I use Ubuntu 18.04 and see spaces in the path…

Any idea how to resolve this?

As it says in Dependencies from private lib disappear after upgrading to Core 5.0.0 · Issue #3649 · platformio/platformio-core · GitHub there was a fix in that direction recently. Does it work with the latest dev core (pio upgrade --dev)?

@maxgerhardt Thanks for your fast reply. Unfortunately, the pio upgrade from 5.0.0 to 5.0.1b1 did not change the output. It looks like related to something else.

Do you have any other suggestions?

Then I think @ivankravets can have a look at it since the example above is very self-contained.

1 Like

Please add #include <Adafruit_I2CDevice.h> to Test.ino.


@ivankravets, Build success!

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>

Adafruit_SSD1306 display(-1);

Thank you very much for your help.


But this is still just a workaround, it should work automatically. Another workaround is to add Adafruit BusIO as a dependency in platformio.ini. But even without doing that, PlatformIO installs BusIO, it just seems that it doesn’t add it to the compiler path.


Came here to say that this was driving me crazy the last few days. Thanks for the work around!

The workaround worked for me and I thank the community for the answer.

I’d like to learn why this didn’t work ‘automagically’. It concerns me that I may run into a similar problem in the future and not know if it’s my code or an anomaly with PlatFormIO. Plus it’s a learning opportunity to find out why this wasn’t 100% transportable from the Arduino IDE. I’ll watch the thread and hopefully learn more about the innards of PlatFormIO

1 Like

This error is caused by how PlatformIO searches for dependencies. If a dependency for a library has a dependency in another library the default ldf mode (chain) only searches header files. using the chain+ mode will not work here because it will only search header files.

If you set the lib_ldf_mode = deep in platformio.ini it will work. This solution is not recommend though.

You can include the dependency in your main code, for example in main.cpp you could add #include <Adafruit_I2CDevice.h>. This will allow ldf to find library and compile it.

The last way to fix it, and probably the best way, is to include the library in platformio.ini with lib_deps.

lib_deps = adafruit/Adafruit SSD1306@^2.4.0,  adafruit/Adafruit BusIO@^1.6.0

This will allow ldf to find the header file it needs.

As a side not, if the GFX library had the include in header for Adafruit_I2CDevice.h then this problem wouldn’t happen.


I love how it’s August 2021 and this problem hasn’t been fixed yet.
We still need to write lib_ldf_mode=deep in platformio.ini.

And in 2022… simple fix is to remove and use makefiles instead.