I'm using PlatformIO, and I'm trying to create a library who uses another library in it.

(1) For that I created an empty library called ABCD.h stored in a newrep github repository.

(2) 3rd party library chosen is Panda_segmentBed_I2C.h with no particular reason.

(3) That library was inserted as needed to lib_deps and initiate build update the newly create library that it pulled 3rd party library as needed, as shown in pic1 enter image description here

(4) ABCD.h includes #include <Panda_segmentBed_I2C.h>

(5) Now to simulate a use of ABCD.h library inside a code, I've created a new project called TEST_NEWREP. Only 1 line was added to project: #include <ABCD.h>

(6) After running build I get an error that 3rd party library, inside ABCD.h is not found.

(7) see TEST_NEWREP tree:

enter image description here

**Edit 1 - update .gitignore **

Somehow, when Project is created, a default .gitignore includes an ignore of .pio library. Perhaps in some cases it should be ignored, but when that Project is a library, it does not upload .pio\libdeps. Now after the exclude is removed, all dependencies are pulled as needed when build the project, BUT STILL ERROR REMAINS THAT Panda_segmentBed_I2C.h is not found.

  • You main.cpp should be in the same source directory with ABCD.h and ABCD.cpp (as a local library), and you declare it as #include "ABCD.h" in your main.cpp.
    – hcheung
    Jun 9, 2022 at 12:28
  • @hcheung but main.cpp is not part of library files.
    – guyd
    Jun 9, 2022 at 12:30
  • You don't need to mess with the .gitignore, when compiling the code, the platformIO will download the library based on your libdeps configuration in your platformio.ini file.
    – hcheung
    Jun 9, 2022 at 12:30
  • If ABCD.h is a separate library, then you only need to set up the libdeps in your platformio.ini to use it. From the first picture you shown, the ABCD.h is not an independent library, but a local file to the project newrep.
    – hcheung
    Jun 9, 2022 at 12:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.