If I delete one of the same library from the /libdeps directory, Platformio will just download them again.
I don’t know how correct is any of this, because, for example, in this project both Adafruit GFX libraries have a Font directory inside, where I add fonts that I want to use. I am adding the font to both libraries, even if they are identical. Isn’t this making the build file larger ?
Any ideas as to why I’m getting this strange behavior ?
I am getting conflicting code errors because it’s the same code twice.
I can’t modify a library because I don’t know which one will get used.
Indexing .pio/build/esp32doit-devkit-v1/libFrameworkArduino.a
Linking .pio/build/esp32doit-devkit-v1/firmware.elf
.pio/build/esp32doit-devkit-v1/lib8d2/FastLED@src-840563c23c8dae79803694244a6818ef/FastLED.cpp.o: In function `CFastLED::CFastLED()':
/home/georgeflorian/Documents/PlatformIO/Projects/ESP_TimerOnInput-main/.pio/libdeps/esp32doit-devkit-v1/FastLED@src-840563c23c8dae79803694244a6818ef/src/FastLED.cpp:24: multiple definition of `CFastLED::CFastLED()'
.pio/build/esp32doit-devkit-v1/libb5a/FastLED/FastLED.cpp.o:/home/georgeflorian/Documents/PlatformIO/Projects/ESP_TimerOnInput-main/.pio/libdeps/esp32doit-devkit-v1/FastLED/src/FastLED.cpp:24: first defined here
.pio/build/esp32doit-devkit-v1/lib8d2/FastLED@src-840563c23c8dae79803694244a6818ef/FastLED.cpp.o: In function `CFastLED::CFastLED()':
FastLED.cpp:(.text._ZN8CFastLEDC2Ev+0x0): multiple definition of `CFastLED::CFastLED()'
.pio/build/esp32doit-devkit-v1/lib8d2/FastLED@src-840563c23c8dae79803694244a6818ef/power_mgt.cpp.o: In function `show_at_max_brightness_for_power()':
power_mgt.cpp:(.text._Z32show_at_max_brightness_for_powerv+0x0): multiple definition of `show_at_max_brightness_for_power()'
.pio/build/esp32doit-devkit-v1/libb5a/FastLED/power_mgt.cpp.o:power_mgt.cpp:(.text._Z32show_at_max_brightness_for_powerv+0x0): first defined here
.pio/build/esp32doit-devkit-v1/lib8d2/FastLED@src-840563c23c8dae79803694244a6818ef/power_mgt.cpp.o: In function `delay_at_max_brightness_for_power(unsigned short)':
power_mgt.cpp:(.text._Z33delay_at_max_brightness_for_powert+0x0): multiple definition of `delay_at_max_brightness_for_power(unsigned short)'
.pio/build/esp32doit-devkit-v1/libb5a/FastLED/power_mgt.cpp.o:power_mgt.cpp:(.text._Z33delay_at_max_brightness_for_powert+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32doit-devkit-v1/firmware.elf] Error 1
That looks correct, but each library could have additional dependencies which are pulled via the regular PlatformIO registry and not via git, and that might result in that behavior. I’ll try it out.
Hm yes it is as I thought. When you reference a library via git that has sub-dependencies, like e.g. ESPAsyncWebServer has on AsyncTCP, you will get the git version of ESPAsyncWebServer but then the regular version of the dependencies
So the git version of ESP Async Websever is itself of the git version, bubt the dependency is of the regular version. Then both AsyncTCP of the git and regular version are in the dependency graph, too.
Per this the linker will then use the first-available library that satisfies the linking conditions… meaning that one of them will be ignored and it probably depends on the order of the library in the linker command.
That is a problem when the library code is different and you need the sub-dependency to be sourced from the later version as well…
Three things I can recommend:
only source the high-level library from git, in the example above ESP Async WebServer. It will internally then use the stable AsyncTCP version it was tested against.
if you need to a subdependency to also be sourced from git, you should fork the high-level library and change the library.json manifest to reference the git version as well, see dependencies in the library.json
open an issue in Issues · platformio/platformio-core · GitHub so that some resolution for the above mentioned situation can be found in easier managable terms without forking. E.g., if two libraries are present with the same name, and one from git and one regular, introduce an option to prefer the git version, etc.