Library AsyncElegantOTA header from lib not found

Hello. I’ve been trying to use Plattform.io as an Arduino editor (mainly for ESP) for a couple of weeks now. I often have problems with the library integrations - It compiles without problems in Arduino IDE, but raises many errors in Plattform.io. For example, i needed to copy the SD library from Arduino into the lib folder because the “internal” library for the ESP32 did not work (although it should be the same).

Current problem which i dont understand: I use AsyncElegantOTA (togetger with ESPAsyncWebServer). The AsyncElegantOTA library ( ayushsharma82/AsyncElegantOTA @ ^2.2.5) did install without any problems, but although the AsyncElegantOTA .h header file is clearly in the library source folder, i get an error (it seems AsyncElegantOTA is not added to the dependency graph althouhg included):

    Processing esp-wrover-kit (platform: espressif32; board: esp-wrover-kit; framework: arduino)
  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp-wrover-kit.html
PLATFORM: Espressif 32 (3.2.0) > Espressif ESP-WROVER-KIT
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (ftdi) On-board (ftdi) 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.10006.210326 (1.0.6)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ strict
Found 30 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.0
|-- <ESP Async WebServer> 1.2.3
|   |-- <AsyncTCP> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <AsyncTCP> 1.1.1
Building in release mode
Compiling .pio\build\esp-wrover-kit\src\main.cpp.o
Archiving .pio\build\esp-wrover-kit\lib79f\libWiFi.a
Archiving .pio\build\esp-wrover-kit\libd37\libAsyncTCP.a
Compiling .pio\build\esp-wrover-kit\libe01\FS\FS.cpp.o
Compiling .pio\build\esp-wrover-kit\libe01\FS\vfs_api.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\AsyncEventSource.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\AsyncWebSocket.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\SPIFFSEditor.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebAuthentication.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebHandlers.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebRequest.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebResponses.cpp.o
src\main.cpp:28:29: fatal error: AsyncElegantOTA.h: No such file or directory

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

compilation terminated.
*** [.pio\build\esp-wrover-kit\src\main.cpp.o] Error 1
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebServer.cpp.o

Also changing the lib ldf mode to chain+ did not work.

minimal plattformio.ini:

[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
lib_compat_mode = strict
lib_ldf_mode = chain+
lib_deps = 
    WiFi 
    ESP Async WebServer
    ayushsharma82/AsyncElegantOTA @ ^2.2.5

minimal sourcecode example:

#include "Arduino.h"
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>


const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

AsyncWebServer server(80);

void setup(void) {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "Hi! I am ESP8266.");
  });

  AsyncElegantOTA.begin(&server);    // Start ElegantOTA
  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  AsyncElegantOTA.loop();
}

Remove this line from the platformio.ini.

The library uses a more outdated

syntax of saying ESP8266 & ESP32 support, but this should have been done as

"platforms": ["espressif8266", "espressif32"]

nowadays and thus it probably fails the strict check.

That did work. I had added the strict compat mode because i got a ton of other errors when not using strict mode. There SD library seems to have problems then.

Dependency Graph
|-- <WiFi> 1.0
|-- <ESP Async WebServer> 1.2.3
|   |-- <AsyncTCP> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <SD> 0.0.0-alpha+sha.041f788250
|   |-- <SPI> 1.0
|-- <AsyncElegantOTA> 2.2.5
|   |-- <WiFi> 1.0
|   |-- <AsyncTCP> 1.1.1
|   |-- <Update> 1.0
|   |-- <ESP Async WebServer> 1.2.3
|   |   |-- <AsyncTCP> 1.1.1
|   |   |-- <FS> 1.0
|   |   |-- <WiFi> 1.0
|   |-- <FS> 1.0
|-- <SPI> 1.0
|-- <AsyncTCP> 1.1.1
|-- <FS> 1.0
|-- <Update> 1.0
Building in release mode
Compiling .pio\build\esp-wrover-kit\src\main.cpp.o
Generating partitions .pio\build\esp-wrover-kit\partitions.bin
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\ETH.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFi.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiAP.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiClient.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiGeneric.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiMulti.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiSTA.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiScan.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiServer.cpp.o
Compiling .pio\build\esp-wrover-kit\lib79f\WiFi\WiFiUdp.cpp.o
Compiling .pio\build\esp-wrover-kit\libd37\AsyncTCP\AsyncTCP.cpp.o
In file included from .pio\libdeps\esp-wrover-kit\SD/utility/Sd2Card.h:26:0,
                 from .pio\libdeps\esp-wrover-kit\SD/utility/SdFat.h:29,
                 from .pio\libdeps\esp-wrover-kit\SD/SD.h:25,
                 from src\main.cpp:25:
.pio\libdeps\esp-wrover-kit\SD/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
 #error Architecture or board not supported.
  ^
In file included from .pio\libdeps\esp-wrover-kit\ESP Async WebServer\src/ESPAsyncWebServer.h:27:0,
                 from src\main.cpp:28:
C:\Users\hstasch\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:30:0: warning: "FILE_READ" redefined
 #define FILE_READ       "r"
 ^
In file included from src\main.cpp:25:0:
.pio\libdeps\esp-wrover-kit\SD/SD.h:28:0: note: this is the location of the previous definition
 #define FILE_READ O_READ
 ^
In file included from .pio\libdeps\esp-wrover-kit\ESP Async WebServer\src/ESPAsyncWebServer.h:27:0,
                 from src\main.cpp:28:
C:\Users\hstasch\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:31:0: warning: "FILE_WRITE" redefined
 #define FILE_WRITE      "w"
 ^
In file included from src\main.cpp:25:0:
.pio\libdeps\esp-wrover-kit\SD/SD.h:29:0: note: this is the location of the previous definition
 #define FILE_WRITE (O_READ | O_WRITE | O_CREAT)
 ^
In file included from .pio\libdeps\esp-wrover-kit\SD/utility/SdFat.h:29:0,
                 from .pio\libdeps\esp-wrover-kit\SD/SD.h:25,
                 from src\main.cpp:25:
.pio\libdeps\esp-wrover-kit\SD/utility/Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
 uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
                                     ^
.pio\libdeps\esp-wrover-kit\SD/utility/Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
 uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
                               ^
.pio\libdeps\esp-wrover-kit\SD/utility/Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
 uint8_t const  SPI_MISO_PIN = MISO_PIN;
                               ^
.pio\libdeps\esp-wrover-kit\SD/utility/Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
 uint8_t const  SPI_SCK_PIN = SCK_PIN;
                              ^
In file included from .pio\libdeps\esp-wrover-kit\ESP Async WebServer\src/ESPAsyncWebServer.h:27:0,
                 from src\main.cpp:28:
C:\Users\hstasch\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:118:11: error: 'File' is already declared in this scope
 using fs::File;
           ^
Compiling .pio\build\esp-wrover-kit\libe01\FS\FS.cpp.o
Compiling .pio\build\esp-wrover-kit\libe01\FS\vfs_api.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\AsyncEventSource.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\AsyncWebSocket.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\SPIFFSEditor.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebAuthentication.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebHandlers.cpp.o
Archiving .pio\build\esp-wrover-kit\lib79f\libWiFi.a
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebRequest.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebResponses.cpp.o
Compiling .pio\build\esp-wrover-kit\lib03b\ESP Async WebServer\WebServer.cpp.o
Archiving .pio\build\esp-wrover-kit\libd37\libAsyncTCP.a
Compiling .pio\build\esp-wrover-kit\lib880\SPI\SPI.cpp.o
*** [.pio\build\esp-wrover-kit\src\main.cpp.o] Error 1

For that, add library SD to lib_deps:

[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
upload_port = COM7
board_build.partitions = min_spiffs.csv
monitor_port = COM7
monitor_speed = 115200
lib_ldf_mode = chain+
lib_deps = 
    WiFi 
    ESP Async WebServer
    SD
    ayushsharma82/AsyncElegantOTA @ ^2.2.5

and add #include <SD.h> to the sourcecode.

You need to add the ESP32 version of the SD library, which is named

in the core, not SD, as that will give you a version meant for AVRs. Replace SD with SD(esp32) in the platformio.ini and it will work.

1 Like

Wow thanks that did the trick :slight_smile: Is there a list for device specific libraries like sd which need another name somewehere?

Actually, I should revise my advice: Any library that is built into the Arduino core will be recognizes without adding it to lib_deps, since they are automatically in the library search path. So if you just add #include <SD.h> to the main.cpp (and remove the .pio folder of the project to clear any old artefacts), it will also work and pick up the correct library.

Of course, you can still call all libraries by name. For the name, look into the name field of the library manifest data file, that is the library.properties or library.json file. All available libraries for a core are in the libraries/ folder of that core, e.g. https://github.com/espressif/arduino-esp32/tree/master/libraries.

For all other libraries, use https://platformio.org/lib.