Adding library to project breaks it

trying to modify a firmware for an esp-cam. cloneing git, fresh download builds fine. but when i add another library it stops building and starts throwing errors about missing files for things that werent a problem the moment before, and i havnt even changed anything else. it appears that adding the library does a number on the platformio.ini file, including deleting a BUNCH of commented lines and its confusing and frustrating that i dont understand WHY it would do that or how to revert whatever it does.

Very hard to answer with this little information.

  • What are the errors? (log?)
  • Which project from github (link?)
  • What libraries are added (link? / name?)

So I am guessing that you have some troubles with the LDF when adding a library to the lib_deps without including the library into the source code.

Changing the LDF-Mode to chain+, deep or deep+ might help.

But without detailed information, this is just a guess…

if you want to try and reproduce, i forked GitHub - rzeldent/esp32cam-rtsp: Simple RTSP (streaming image) server for the ESP32CAM. Easy configuration and monitoring through the web interface. and tried to add ps4 host controller something: GitHub - pablomarquez76/PS4_Controller_Host: Allows ESP32 to communicate with PS4 controller (can be used to control robots and other devices). after adding it starts throwing errors about missing ov2460 and IoTWebConf among others, all things that are very much part of the original file. LDF sounds extremely relevant, ill look into that, thank you

so after starting over in another partition (in case i was having space issues again) i tried again, and instead of using the gui>platformio>libraries>search>add to project(which resulted in the near destruction of the platformio.ini), i just added the single line to lib_deps. seems to work, will find out for sure as i add the rest of the functionality

Thanks for sharing the details. Now I was able to follow you :slight_smile:

Threre seems to be some kind of a bug, partially…

Using the GUI to add the library…

  • worked fine for me on Windows.
    The library was added to all the sections in the platformio.ini

  • On WSL / Ubuntu something strange happened
    The library was cloned into the projects root directory

What’s your system and what happened exactly to your project?

ha! im running windows 10. from what i could tell it was adding a new line for every board enviroment to include the dependency, and deleting every commented line. i think it also either deleted or moved other lines that were important? im honestly not sure, just that building failed and once i manually added the single line everything works, at least as far as platformio goes, it doesnt look like the library is going to play nice with the camera, but thats for a different forum

That’s exactly what it should do. This is correct

Are you 100% sure about this?
This did not happened to me.

Solution: Add the dependencies manually.
I think the GUI was made for more simpler projects with a single environment - for beginners.

Your example projects is for advanced to expirienced users. Those would add the lib_deps manually :wink:

yes. sortof:

so at least lines commented out by #

ok more wierdness, but i have the actual logs this time. was having issues with the project, so decided to try to add the lib_deps line to the board environment. this is what i got when i next built it: Processing esp32cam_ai_thinker (board: esp32cam_ai_thinker; platform: espressif32; framework: arduino) --------------------------------------------------------------------------------------------------------Removing unused dependencies... Library Manager: Removing Micro-RTSP @ 0.1.6 Library Manager: Micro-RTSP@0.1.6 has been removed! Library Manager: Removing IotWebConf @ 3.2.1 Library Manager: IotWebConf@3.2.1 has been removed! Library Manager: Removing micro-moustache @ 1.0.1 Library Manager: micro-moustache@1.0.1 has been removed! Verbose mode can be enabled via -v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam_ai_thinker.html
PLATFORM: Espressif 32 (6.10.0) > ESP32CAM AI Thinker
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.241212+sha.dcc1105b
  • tool-esptoolpy @ 1.40501.0 (4.5.1)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 36 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- PS4_Controller_Host @ 1.0.9
    |-- ESPmDNS @ 2.0.0
    |-- RTSPServer @ 1.0.0
    Building in release mode
    prepare_file([“.pio\build\esp32cam_ai_thinker\index.min.html.txt.o”], [“html\index.min.html”])
    Converting .pio\build\esp32cam_ai_thinker\index.min.html.txt.o
    revert_original_file([“.pio\build\esp32cam_ai_thinker\index.min.html.txt.o”], [“html\index.min.html”])
    Compiling .pio\build\esp32cam_ai_thinker\src\main.cpp.o
    Building .pio\build\esp32cam_ai_thinker\bootloader.bin
    Generating partitions .pio\build\esp32cam_ai_thinker\partitions.bin
    esptool.py v4.5.1
    Creating esp32 image…
    Merged 1 ELF section
    Successfully created esp32 image.
    Compiling .pio\build\esp32cam_ai_thinker\lib6cb\PS4_Controller_Host\PS4Controller.cpp.o
    Compiling .pio\build\esp32cam_ai_thinker\lib6cb\PS4_Controller_Host\ps4.c.o
    Compiling .pio\build\esp32cam_ai_thinker\lib6cb\PS4_Controller_Host\ps4_l2cap.c.o
    Compiling .pio\build\esp32cam_ai_thinker\lib6cb\PS4_Controller_Host\ps4_parser.c.o
    Compiling .pio\build\esp32cam_ai_thinker\lib6cb\PS4_Controller_Host\ps4_spp.c.o
    .pio/libdeps/esp32cam_ai_thinker/PS4_Controller_Host/src/ps4.c: In function ‘ps4Deinit’:
    .pio/libdeps/esp32cam_ai_thinker/PS4_Controller_Host/src/ps4.c:59:5: warning: implicit declaration of function ‘spp_deinit’; did you mean ‘sppInit’? [-Wimplicit-function-declaration]
    spp_deinit();
    ^~~~~~~~~~
    sppInit
    Compiling .pio\build\esp32cam_ai_thinker\lib534\WiFi\WiFi.cpp.o
    Compiling .pio\build\esp32cam_ai_thinker\lib534\WiFi\WiFiAP.cpp.o
    Compiling .pio\build\esp32cam_ai_thinker\lib534\WiFi\WiFiClient.cpp.o
    Compiling .pio\build\esp32cam_ai_thinker\lib534\WiFi\WiFiGeneric.cpp.o
    Compiling .pio\build\esp32cam_ai_thinker\lib534\WiFi\WiFiMulti.cpp.o
    Compiling .pio\build\esp32cam_ai_thinker\lib534\WiFi\WiFiSTA.cpp.o
    src/main.cpp:5:10: fatal error: IotWebConf.h: No such file or directory

  • Looking for IotWebConf.h dependency? Check our library registry!
  • CLI > platformio lib search “header:IotWebConf.h”
  • Web > PlatformIO Registry

#include <IotWebConf.h>
^~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32cam_ai_thinker\src\main.cpp.o] Error 1
====================================== [FAILED] Took 9.37 seconds ======================================
Environment Status Duration


esp32cam_ai_thinker FAILED 00:00:09.368
================================ 1 failed, 0 succeeded in 00:00:09.368 ================================

  • The terminal process “C:\Users\robert.platformio\penv\Scripts\platformio.exe ‘run’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it. `

so it removed some files, then complains about the files it just removed?

edit: ok so build environment deps overide the previous list of deps. put the full list in both places and i think its working now? and yes im very much in over my head, but only barely i think so itll be fine eventually

for future googlers: the problem ultimately was that it wasnt adding the rest of the required libraries when it added the lib_deps to the board envs, so the board env takes precedent, and ignores the rest of the required libraries.