Problem with multiple versions of same library in the project

Hi

I have project which depends on several different libraries. There is issue because some of those libraries as dependencies include different versions of the same libraries.

As far I can pin it down, problem is combination of ayushsharma82/ElegantOTA which includes as dependency some specific versions of ESP32Async/ESPAsyncWebServer and ESP32Async/AsyncTCP and at the same time I’m referencing same libraries but latest versions (for my web part of the code).

When I compile the code, it ends with lot of warnings (for AsyncTCP.c) and at the end it fails, here is just a sample:

C:\Users\Ivan\OneDrive\Projects\PIO\ESP32\eGrunt\v1.0.1/.pio/libdeps/stable/AsyncTCP/src/AsyncTCP.cpp:813: multiple definition of `AsyncClient::onPacket(std::function<void (void*, AsyncClient*, pbuf*)>, void*)'; .pio/build/stable/lib7fd/libAsyncTCP@3.3.2.a(AsyncTCP.cpp.o):C:\Users\Ivan\OneDrive\Projects\PIO\ESP32\eGrunt\v1.0.1/.pio/libdeps/stable/AsyncTCP@3.3.2/src/AsyncTCP.cpp:776: first defined here      
C:/Users/Ivan/.platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld.exe: .pio/build/stable/libb00/libAsyncTCP.a(AsyncTCP.cpp.o): in function `AsyncClient::onTimeout(std::function<void (void*, AsyncClient*, unsigned long)>, void*)':
C:\Users\Ivan\OneDrive\Projects\PIO\ESP32\eGrunt\v1.0.1/.pio/libdeps/stable/AsyncTCP/src/AsyncTCP.cpp:818: multiple definition of `AsyncClient::onTimeout(std::function<void (void*, AsyncClient*, unsigned long)>, void*)'; .pio/build/stable/lib7fd/libAsyncTCP@3.3.2.a(AsyncTCP.cpp.o):C:\Users\Ivan\OneDrive\Projects\PIO\ESP32\eGrunt\v1.0.1/.pio/libdeps/stable/AsyncTCP@3.3.2/src/AsyncTCP.cpp:781: first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\stable\firmware.elf] Error 1

platformio.ini

[env:stable]
board = esp32-s3-devkitc-1-n16r8v
;platform = espressif32
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
framework = arduino
monitor_speed = 115200
monitor_filters = 
	esp32_exception_decoder
	direct
	time
	log2file
build_flags = 
	-D CONFIG_ARDUHAL_LOG_COLORS=1
	-D CORE_DEBUG_LEVEL=3
	-D USE_ESP_IDF_LOG=1
	-D TAG="\"Arduino\""
	-D MQTT_MAX_PACKET_SIZE=1024
	-D CONFIG_LOG_COLORS=1
	-D ENABLE_SDCARD_LOGGING=0	;my flag that enables SD card logging
	-D ELEGANTOTA_USE_ASYNC_WEBSERVER=1
	-D CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN=1	; until <driver/pulse.h> is migrated to <driver/pulse_cnt.h>
;board_build.partitions = min_spiffs.csv
lib_compat_mode = strict
lib_ldf_mode = deep
lib_deps = 
	knolleary/PubSubClient@^2.8
	Wire
	bblanchon/ArduinoJson@^7.1.0
	adafruit/Adafruit Unified Sensor@^1.1.14
	adafruit/Adafruit BMP280 Library@^2.6.8
	adafruit/Adafruit AHTX0@^2.0.5
	adafruit/Adafruit ADS1X15@^2.5.0	
	adafruit/RTClib@^2.1.4
	mobizt/ESP_SSLClient@^2.1.16
	ayushsharma82/ElegantOTA@^3.1.6
	ESP32Async/AsyncTCP
  	ESP32Async/ESPAsyncWebServer

Pls note that platform is set to pioarduino in order to use Arduino Core 3.

What I have tried so far is changing lib_ldf_mode between strict and deep, as well deleting libdeps folder, but no result. My current workaround is to comment out last two lib_deps entries (AsyncTCP and ESPAsyncWebServer), which mean I’m using older versions of them included as dependencies for ElegantOTA library.

Here is how libdeps folder looks like:

What is strange is when I create test dummy project with same platformio.ini settings and include following libs, everything is OK:

  • ayushsharma82/ElegantOTA@^3.1.6
  • ESP32Async/AsyncTCP
  • ESP32Async/ESPAsyncWebServer

It compiles fine, here is how libraries are installed in fresh project:

Library Manager: Installing ayushsharma82/ElegantOTA @ ^3.1.6
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: ElegantOTA@3.1.6 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing mathieucarbou/ESPAsyncWebServer @ ^3.3.11
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: ESPAsyncWebServer@3.6.0 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing mathieucarbou/AsyncTCP @ ^3.3.2
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: AsyncTCP@3.3.2 has been installed!
Library Manager: Installing ESP32Async/AsyncTCP
Unpacking  [####################################]  100%
Library Manager: AsyncTCP@3.3.7 has been installed!
Library Manager: Installing ESP32Async/ESPAsyncWebServer
Unpacking  [####################################]  100%
Library Manager: ESPAsyncWebServer@3.7.3 has been installed!
Library Manager: Resolving dependencies...

Any idea, hint?

Afaik you can’t have the same library in different versions in one project. This will always lead to collisions.

All you can do is either

  • a) use the same version of ESP32Async/ESPAsyncWebServer in your project which is used by ayushsharma82/ElegantOTA
  • b) Wait until ayushsharma82/ElegantOTA is updated and using the newer version of ESP32Async/ESPAsyncWebServer

But does your code make use of the libraries code? If not, the compiler / linker will optimize out the things that you do not use in your project. This will also optimize out collisions and no collisions will happen.

Thx. In the dummy project I did just include the libraries in the project, but not actually used them in the code, which would explain why there was not collision.

I was also searching ElegantOTA library documentation for some reference to this and have found this:

Did as it was mentioned - now I have only one version of each library.

Good to know that project can have only version of given library, although this can complicated things in cases where there are strict dependencies on different version.

Anyway, thx for the support. :+1:

Ivan

This is not an issue from Platformio. “Just” conflicts in dependencies from the used libs.