Multiple ArduinoSTL errors when trying to move project from Arduino IDE

I have used Arduino IDE for many years, and tinkered with PlatformIO during that time. But I have now decided to invest the time to make the switch fully to Platform IO and continue my projects in it going forward.

For my first project to convert, I have added the libraries to the platform.ini file and it compiles fine at that point and I can even call most of the libraries (I still need to working out OTA), but when calling pubsubclient, I start getting many errors including with ArduinoSTL.

I have tried some different platform versions, and libraries, but I do not feel I am on the right path yet and could use some help getting there.

Here is what compiles fine.

[env:esp32dev]
platform = espressif32
;platform = espressif32 @ 6.8.1
board = esp32dev
framework = arduino
;framework = arduino,
monitor_speed = 115200
lib_deps = 
	knolleary/PubSubClient@^2.8
	;PubSubClient
	adafruit/Adafruit Unified Sensor@^1.1.14
	adafruit/Adafruit BME280 Library@^2.2.4
	fabianoriccardi/Dimmable Light for Arduino@^1.6.0
	adafruit/Adafruit BusIO@^1.16.2
	Wire
	SPI
	;mike-matera/ArduinoSTL@^1.3.3
#include <Arduino.h>
//#include <WiFi.h>               // WiFi module
//#include <PubSubClient.h>       // MQTT
///#include <WebServer.h>          // for OTA
///#include <ESPmDNS.h>            // for OTA
//#include <Update.h>             // for OTA
#include <Wire.h>               // for BME280
#include <Adafruit_Sensor.h>    // for BME280
#include <Adafruit_BME280.h>    // for BME280
#include "dimmable_light.h"     // for Dimmer


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

void loop() {
  // put your main code here, to run repeatedly:
}
Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.9.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, 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.20017.0 (2.0.17)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- PubSubClient @ 2.8.0
|-- Adafruit Unified Sensor @ 1.1.14
|-- Adafruit BME280 Library @ 2.2.4
|-- Dimmable Light for Arduino @ 1.6.0
|-- Adafruit BusIO @ 1.16.2
|-- Wire @ 2.0.0
|-- SPI @ 2.0.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.4% (used 21032 bytes from 327680 bytes)
Flash: [==        ]  17.8% (used 233241 bytes from 1310720 bytes)
=========================================================== [SUCCESS] Took 12.81 seconds ===========================================================

Now if I add the pubsubclient library call

#include <Arduino.h>
//#include <WiFi.h>               // WiFi module
#include <PubSubClient.h>       // MQTT
///#include <WebServer.h>          // for OTA
///#include <ESPmDNS.h>            // for OTA
//#include <Update.h>             // for OTA
#include <Wire.h>               // for BME280
#include <Adafruit_Sensor.h>    // for BME280
#include <Adafruit_BME280.h>    // for BME280
#include "dimmable_light.h"     // for Dimmer


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

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

         ^~~
In file included from C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:196,
                 from .pio/libdeps/esp32dev/ArduinoSTL/src/ArduinoSTL.h:12,
                 from .pio/libdeps/esp32dev/ArduinoSTL/src/ArduinoSTL.cpp:1:
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/HardwareSerial.h:217:20: error: 'OnReceiveCb' has not been declared     
     void onReceive(OnReceiveCb function, bool onlyOnTimeout = false);
                    ^~~~~~~~~~~
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/HardwareSerial.h:220:25: error: 'OnReceiveErrorCb' has not been declared     void onReceiveError(OnReceiveErrorCb function);
                         ^~~~~~~~~~~~~~~~
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/HardwareSerial.h:308:5: error: 'OnReceiveCb' does not name a type       
     OnReceiveCb _onReceiveCB;
     ^~~~~~~~~~~
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/HardwareSerial.h:309:5: error: 'OnReceiveErrorCb' does not name a type
     OnReceiveErrorCb _onReceiveErrorCB;
     ^~~~~~~~~~~~~~~~
In file included from .pio/libdeps/esp32dev/ArduinoSTL/src/ArduinoSTL.h:12,
                 from .pio/libdeps/esp32dev/ArduinoSTL/src/ArduinoSTL.cpp:1:
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:202:12: error: 'std::isinf' has not been declared
 using std::isinf;
            ^~~~~
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:203:12: error: 'std::isnan' has not been declared
 using std::isnan;
            ^~~~~
C:/Users/User/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:206:12: error: 'std::round' has not been declared
 using std::round;
            ^~~~~
*** [.pio\build\esp32dev\lib4c0\ArduinoSTL\ArduinoSTL.cpp.o] Error 1
=========================================================== [FAILED] Took 19.24 seconds ===========================================================

image

Now the interesting part… If I enable only pubsubclient in the platform.ini file and call only it in the main.cpp then it compiles fine too.

Here is the link to the pubsubclient doc
https://registry.platformio.org/libraries/knolleary/PubSubClient

After some rest since trying to work this out yesterday, I do have it narrowed down some. It is the pubsubclient and dimmable light for Arduino packages together that cause the errors.

I can run all the other packages with either of those two and it will compiles, but with them together, I have the errors mentioned. If I was using an older version on the arduino IDE then that would make sense of it too.

I just checked and the pubsubclient library I was using was current, but the dimmable light library was v1.4.0 on my old arduino IDE project. But the library was not setup to use platformIO until v1.5.0. So I guess I can not just go back to the version I was using unless I stay with Arduino IDE. I will open an issue in Github with the error, but I wish I understood the two libraries well enough to find a work around for now.

I rather believe that the ArduinoSTL library is the cause.
The ESP32 framework already has STL functions implemented. This library causes collisions.

Unfortunately, the Dimmable Light library is dependent on the ArduinoSTL. This makes it incompatible to the ESP32.

Solution: Find a replacement for the Dimmable Light library that is compatible with the ESP32.

As long as I do not include the two together then it complies fine though, so I am a bit confused. Here it is with Dimmable Light without pubsubclient. And the link for the compatibility of the library.
https://registry.platformio.org/libraries/fabianoriccardi/Dimmable%20Light%20for%20Arduino/compatibility

[env:esp32dev]
platform = espressif32
;platform = espressif32 @ 6.8.1
board = esp32dev
framework = arduino
;framework = arduino,
monitor_speed = 115200
lib_deps = 
	;knolleary/PubSubClient@^2.8
	;PubSubClient
	adafruit/Adafruit Unified Sensor@^1.1.14
	adafruit/Adafruit BME280 Library@^2.2.4
	fabianoriccardi/Dimmable Light for Arduino@^1.5.0
	adafruit/Adafruit BusIO@^1.16.2
	Wire
	SPI
	;mike-matera/ArduinoSTL@^1.3.3
#include <Arduino.h>
//#include <WiFi.h>               // WiFi module
//#include <PubSubClient.h>       // MQTT
///#include <WebServer.h>          // for OTA
///#include <ESPmDNS.h>            // for OTA
//#include <Update.h>             // for OTA
#include <Wire.h>               // for BME280
#include <Adafruit_Sensor.h>    // for BME280
#include <Adafruit_BME280.h>    // for BME280
#include <dimmable_light.h>     // for Dimmer


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

void loop() {
  // put your main code here, to run repeatedly:
}
Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.9.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, 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.20017.0 (2.0.17)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Adafruit Unified Sensor @ 1.1.14
|-- Adafruit BME280 Library @ 2.2.4
|-- Dimmable Light for Arduino @ 1.6.0
|-- Adafruit BusIO @ 1.16.2
|-- Wire @ 2.0.0
|-- SPI @ 2.0.0
Building in release mode
Compiling .pio\build\esp32dev\lib260\Wire\Wire.cpp.o
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.4% (used 21032 bytes from 327680 bytes)
Flash: [==        ]  17.8% (used 233241 bytes from 1310720 bytes)
================================================================================================================================ [SUCCESS] Took 5.67 seconds ================================================================================================================================

But I also see ArduinoSTL is not pulled in under libdeps unless I call the Dimmable Light library. The thing is that every time I look for a zero cross AC dimmer library for ESP32 alternative, they all have been falling short in comparison.

Is there a work around to use since each will compile without the other?

It is pulled becaus it is a dependency:

That would be the job of the library developer. Wait for the response to your issue.

Solution:
Move the Dimmable Light library from .pio/build/libdeps/esp32dev into the /lib folder.
Delete the library form the lib_deps in your platformio.ini
Delete the ArduinoSTL library from .pio/build/libdeps/esp32dev

Thank you! @sivar2311
It did now compile, so I can continue working through moving over my project now and see what other issues I am facing.