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 > https://platformio.org/lib/search?query=header:Adafruit_I2CDevice.h
*
****************************************************************************
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:
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?
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.
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
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (2.2.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
- framework-arduino-avr 5.0.0
- toolchain-atmelavr 1.50400.190710 (5.4.0)
Converting Test.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
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 > https://platformio.org/lib/search?query=header:Adafruit_I2CDevice.h
*
****************************************************************************
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.
@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.
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.
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
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.