PlatformIO Community

Where to place dependent libraries of project?

I have started using platformIO and found it easy to learn. I am building some projects for ttgo twatch v1 based on esp32.
I am building this project.Its dependent library is btAudio which is not present in PlatformIO Library.

First, I placed the btAudio library in lib folder of my project and built the project, but it showed ‘No such Wifi.h file’ error.
btAudio needs Wifi.h . So, by placing dependent library in lib, btAudio is unable to see/access Wifi.h .
Second time, I copied all files present in btAudio/src to src folder of my project and built again. This time it built successfully.

I don’t want to keep all the dependent libraries in src folder of my project which makes it unmanageable.
Where should I place my dependent libraries which are not available in PlatformIO Library ?

Here is platformio.ini :

[env:ttgo-t-watch]
platform = espressif32
board = ttgo-t-watch
framework = arduino
monitor_speed = 115200

Interesting, I can’t even get the project compile due to the TTGO T Watch library itself

Compiling .pio\build\t\libb58\TTGO TWatch Library\libraries\U8g2_for_Adafruit_GFX\src\U8g2_for_Adafruit_GFX.cpp.o
In file included from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\../../../U8g2_for_Adafruit_GFX/src/../../TFT_eSPI/TFT_eSPI.h:577:0,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\../../../U8g2_for_Adafruit_GFX/src/U8g2_for_Adafruit_GFX.h:41,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\../GxFont_GFX.h:32,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\../GxEPD.h:21,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\GxGDEH0154D67.h:18,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\GxGDEH0154D67.cpp:14:
.pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEH0154D67\../../../U8g2_for_Adafruit_GFX/src/../../TFT_eSPI/Fonts/GFXFF/GFXFF.h:22:76: fatal error: ../../../Adafruit-GFX-Library/Fonts/FreeMonoBoldOblique12pt7b.h: No such file or directory
compilation terminated.
Compiling .pio\build\t\libb58\TTGO TWatch Library\libraries\U8g2_for_Adafruit_GFX\src\u8g2_fonts.c.o
In file included from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\../../../U8g2_for_Adafruit_GFX/src/../../TFT_eSPI/TFT_eSPI.h:577:0,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\../../../U8g2_for_Adafruit_GFX/src/U8g2_for_Adafruit_GFX.h:41,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\../GxFont_GFX.h:32,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\../GxEPD.h:21,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\GxGDEP015OC1.h:18,
                 from .pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\GxGDEP015OC1.cpp:14:
.pio\libdeps\t\TTGO TWatch Library\src\libraries\GxEPD\src\GxGDEP015OC1\../../../U8g2_for_Adafruit_GFX/src/../../TFT_eSPI/Fonts/GFXFF/GFXFF.h:22:76: fatal error: ../../../Adafruit-GFX-Library/Fonts/FreeMonoBoldOblique12pt7b.h: No such file or directory
compilation terminated.

can you upload your working compiling project to github?

I was getting the same error when my project was in the default location i.e. C:\Users\Jonny\Documents\PlatformIO\Projects. After moving the project to other drive, the error was gone.

Oh, that’s right. Wow, and I thought I had Windows NTFS long paths enabled to not run into this issue – but even after enabling it (again) it still did not help, only moving the project folder.

But then, I can build the bluetooth example with the following platformio.ini

[env:ttgo-t-watch]
platform = espressif32
board = ttgo-t-watch
framework = arduino
monitor_speed = 115200
lib_ldf_mode = deep+
lib_deps =
   xinyuan-lilygo/TTGO TWatch Library @ ^1.4.2
   https://github.com/tierneytim/btAudio/archive/refs/heads/master.zip

it just needed a lib_ldf_mode modification to get the dependencies correctly recognized.

By putting the btAudio reference in lib_deps, it’s downloaded automatically in .pio\libdeps\<env> and just works. But you can also remove it from lib_deps and put the library into lib/, it makes no difference, I have tested it both. (Make sure to remove the .pio folder of the project if you switch between the locations of the library to avoid duplicates)

After adding option ldf_mode = deep+ to platformio.ini. It’s now building successfully.
Thanks a lot.