Can't get library dependencies right

OK, I’m a complete noob to PlatformIO but I’m banging a dent in my desk with my forehead. I’m trying to move a 1300 line Arduino IDE sketch. Works just fine in that IDE. I get hundreds of errors in PlatformIO so I decided to start from the beginning. I installed every library I need and their includes but nothing else. The setup() and loop() are empty. OK, big improvement, now I’m down to just dozens of errors but most seem to relate to dependencies of ArduinoJson.h and Adafruit GFX Library. I’ve checked the dependencies as best as I understand and they seem correct.

What am I missing?

#include <Arduino.h>

// *******************************************************
// ******************* INCLUDES **************************
// *******************************************************
#include "colors.h"                 // frame colors

// For general sketch
#include <ESP8266WiFi.h>            // [builtin]
#include <ArduinoJson.h>            // [manager] v6.19.1
#include <ESP8266HTTPClient.h>      // [builtin] http
// For Wemos TFT 1.4 display shield
#include <Adafruit_GFX.h>           // [manager] v1.10.13 Core graphics library
#include <Adafruit_ST7735.h>        // [manager] v1.9.0 Controller chip
#include <SPI.h>                    // [builtin]

// Time functions by Rop Gonggrijp  // See https://github.com/ropg/ezTime
#include <ezTime.h>                 // [manager] v0.8.3 NTP & timezone
// For basic WiFi OTA
//#include <ESP8266mDNS.h>
//#include <WiFiUdp.h>
//#include <ArduinoOTA.h>

// For HTTPS OTA
#include <ESP8266HTTPClient.h>       // [builtin] http
#include <WiFiClientSecureBearSSL.h> // [builtin] https
#include <ESP8266httpUpdate.h>       // [builtin] OTA
#include "ota.h"                     // web server paths

// For WiFiManager library
#include <LittleFS.h>                // [builtin] LittleFS File System
#include <DNSServer.h>               // [builtin] For webserver
#include <ESP8266WebServer.h>        // [builtin] For webserver
#include <WiFiManager.h>             // [manager] https://github.com/tzapu/WiFiManager
#include <DoubleResetDetector.h>     // [manager] v1.0.3 by Stephen Denne https://github.com/datacute/DoubleResetDetector

void setup() {
  // put your setup code here, to run once:
}

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

========================

src\main.cpp:15:10: fatal error: ArduinoJson.h: No such file or directory
*********************************************************************
* Looking for ArduinoJson.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ArduinoJson.h"
* Web  > https://platformio.org/lib/search?query=header:ArduinoJson.h
*
*********************************************************************
   15 | #include <ArduinoJson.h>            // [manager] v6.19.1
      |          ^~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\d1_mini\src\main.cpp.o] Error 1

======================================

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
    bblanchon/ArduinoJson@^6.19.1
    ropg/ezTime@^0.8.3
    adafruit/Adafruit GFX Library@^1.10.13
    adafruit/Adafruit ST7735 and ST7789 Library@^1.9.0
    tzapu/WiFiManager@^0.16.0
    datacute/DoubleResetDetector@^1.0.3

============================

Unable to reproduce. After adding the adafruit/Adafruit BusIO@^1.11.0, SPI and Wire dependencies and empty dummy files for color.h and ota.h, it compiles fine.

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
    bblanchon/ArduinoJson@^6.19.1
    ropg/ezTime@^0.8.3
    adafruit/Adafruit GFX Library@^1.10.13
    adafruit/Adafruit BusIO@^1.11.0
    adafruit/Adafruit ST7735 and ST7789 Library@^1.9.0
    tzapu/WiFiManager@^0.16.0
    datacute/DoubleResetDetector@^1.0.3
    Wire
    SPI
>pio run
Processing d1_mini (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 (3.2.0) > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 3.30002.0 (3.0.2)
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa 2.100300.210717 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 44 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoJson> 6.19.1
|-- <ezTime> 0.8.3
|   |-- <EEPROM> 1.0
|   |-- <ESP8266WiFi> 1.0
|   |-- <Ethernet> 2.0.0
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|-- <Adafruit GFX Library> 1.10.13
|   |-- <SPI> 1.0
|   |-- <Adafruit BusIO> 1.11.0
|   |   |-- <Wire> 1.0
|   |   |-- <SPI> 1.0
|   |-- <Wire> 1.0
|-- <Adafruit BusIO> 1.11.0
|   |-- <Wire> 1.0
|   |-- <SPI> 1.0
|-- <Adafruit ST7735 and ST7789 Library> 1.9.0
|   |-- <Adafruit GFX Library> 1.10.13
|   |   |-- <SPI> 1.0
|   |   |-- <Adafruit BusIO> 1.11.0
|   |   |   |-- <Wire> 1.0
|   |   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0
|   |-- <SPI> 1.0
|-- <WiFiManager> 0.16.0
|   |-- <DNSServer> 1.1.1
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266WebServer> 1.0
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DoubleResetDetector> 1.0.3
|-- <Wire> 1.0
|-- <SPI> 1.0
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266HTTPClient> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266httpUpdate> 1.3
|   |-- <ESP8266HTTPClient> 1.2
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WebServer> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <LittleFS> 0.1.0
Building in release mode
Compiling .pio\build\d1_mini\liba29\ezTime\ezTime.cpp.o
Compiling .pio\build\d1_mini\src\main.cpp.o
[..]
Linking .pio\build\d1_mini\firmware.elf
Retrieving maximum program size .pio\build\d1_mini\firmware.elf
Checking size .pio\build\d1_mini\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  34.4% (used 28164 bytes from 81920 bytes)
Flash: [===       ]  25.4% (used 264869 bytes from 1044464 bytes)
Building .pio\build\d1_mini\firmware.bin
Creating BIN file ".pio\build\d1_mini\firmware.bin" using "C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\bootloaders\eboot\eboot.elf" and ".pio\build\d1_mini\firmware.elf"
============================================================================ [SUCCESS] Took 15.42 seconds ============================================================================

I’d suggest to

  • remove the .pio folder of the project and rebuild
  • open a CLI and execute pio platform update espressif8266 to make sure the platform is updated.
1 Like

First I installed Adafruit BusIO but it was already installed. Next deleted and rebuilt the .pio folder. No change. Deleted .pio and did the CLI expressif update. Still have the same errors.

I don’t know if this is relevant. It appears in the output window:
[2/9/2022, 6:00:00 PM] Unable to resolve configuration with compilerPath: “C:/Users/KarlB/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-gcc.exe”

Here is the terminal window:

> Executing task in folder WeatherBit restart: C:\Users\User\.platformio\penv\Scripts\platformio.exe run <

Processing d1_mini (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 (3.2.0) > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 3.30002.0 (3.0.2)
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa 2.100300.210717 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 44 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoJson> 6.19.1
|-- <ezTime> 0.8.3
|   |-- <EEPROM> 1.0
|   |-- <ESP8266WiFi> 1.0
|   |-- <Ethernet> 2.0.0
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|-- <Adafruit GFX Library> 1.10.13
|   |-- <SPI> 1.0
|   |-- <Adafruit BusIO> 1.11.0
|   |   |-- <SPI> 1.0
|-- <Adafruit ST7735 and ST7789 Library> 1.9.0
|   |-- <Adafruit GFX Library> 1.10.13
|   |   |-- <SPI> 1.0
|   |   |-- <Adafruit BusIO> 1.11.0
|   |   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|-- <WiFiManager> 0.16.0
|   |-- <DNSServer> 1.1.1
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266WebServer> 1.0
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <DoubleResetDetector> 1.0.3
|-- <Adafruit BusIO> 1.11.0
|   |-- <SPI> 1.0
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266HTTPClient> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266httpUpdate> 1.3
|   |-- <ESP8266HTTPClient> 1.2
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WebServer> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <LittleFS> 0.1.0
|-- <SPI> 1.0
Building in release mode
Compiling .pio\build\d1_mini\lib340\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Compiling .pio\build\d1_mini\lib340\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
Compiling .pio\build\d1_mini\lib3a5\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
Archiving .pio\build\d1_mini\libe20\libAdafruit ST7735 and ST7789 Library.a
Archiving .pio\build\d1_mini\lib507\libDNSServer.a
Archiving .pio\build\d1_mini\lib370\libESP8266WebServer.a
Archiving .pio\build\d1_mini\lib9eb\libWiFiManager.a
Compiling .pio\build\d1_mini\libb91\DoubleResetDetector\DoubleResetDetector.cpp.o
In file included from .pio\libdeps\d1_mini\Adafruit BusIO/Adafruit_BusIO_Register.h:9,
                 from .pio\libdeps\d1_mini\Adafruit BusIO\Adafruit_BusIO_Register.cpp:1:
.pio\libdeps\d1_mini\Adafruit BusIO/Adafruit_I2CDevice.h:5:10: 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
*
**************************************************************

    5 | #include <Wire.h>
      |          ^~~~~~~~
compilation terminated.
In file included from .pio\libdeps\d1_mini\Adafruit BusIO\Adafruit_I2CDevice.cpp:1:
.pio\libdeps\d1_mini\Adafruit BusIO\Adafruit_I2CDevice.h:5:10: 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
*
**************************************************************

    5 | #include <Wire.h>
      |          ^~~~~~~~
compilation terminated.
Compiling .pio\build\d1_mini\libd8e\ESP8266HTTPClient\ESP8266HTTPClient.cpp.o
In file included from .pio\libdeps\d1_mini\Adafruit GFX Library\Adafruit_GrayOLED.h:30,
                 from .pio\libdeps\d1_mini\Adafruit GFX Library\Adafruit_GrayOLED.cpp:20:
.pio\libdeps\d1_mini\Adafruit BusIO/Adafruit_I2CDevice.h:5:10: 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
*
**************************************************************

    5 | #include <Wire.h>
      |          ^~~~~~~~
compilation terminated.
Compiling .pio\build\d1_mini\libf6c\ESP8266httpUpdate\ESP8266httpUpdate.cpp.o
*** [.pio\build\d1_mini\lib340\Adafruit BusIO\Adafruit_I2CDevice.cpp.o] Error 1
*** [.pio\build\d1_mini\lib340\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o] Error 1
*** [.pio\build\d1_mini\lib3a5\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o] Error 1
=================================== [FAILED] Took 3.53 seconds ===================================
The terminal process "C:\Users\User\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.

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

Are there any libraries in C:\Users\KarlB\.platformio\lib? Adding a #include <Wire.h> to the main.cpp file doesn’t help?

Success! Maybe… Adding #include <Wire.h> worked. I will try adding code back to this skeleton.

Should there be a `C:\Users\KarlB.platformio\lib folder? There is none on my system.

Thank you so much for your help. I’m looking forward to moving over to PlatformIO.

1 Like

It works great! Moved all 1400 lines and added function prototypes (30) before setup() and loop(). Then did some cleanup of other bad habits from long use of the Arduino IDE.