Internal libraries not found by dependency walker when specified in cpp files

On compilation of a project I got:

fatal error: Wire.h: No such file or directory

In my library I get the following dependency tree on running test:
Library Dependency Graph
|-- I2C
|-- CommonMasks

I2C actually depends on Wire. Wire.h is included in the I2C.cpp file and specified as dependency in the I2C/platformio.ini as lib_deps = Wire.

The only way to make my library compileable is by including Wire.h in I2C.h instead of in I2C.cpp.
Library Dependency Graph
|-- I2C
| |-- Wire v1.0
|-- CommonMasks

Does the dependency walker only walk through headers and not through cpp files? This would require me to specify the includes in the header although they are only required in the internals.

This is the default behavior, you can change it. See Library Dependency Finder (LDF) — PlatformIO latest documentation

Nevertheless, just add #include <Wire.h> to one of the file from your project (not a library) and PIO will build it. Or… you can use lib_deps = Wire.

In any case, please read Redirecting...

Thank your for the answer and the url to the docs. Somehow searching for the error did not give me the proper information. Both solutions work.

After fiddling around some more I discovered that the dependency finder finds the 2nd degree dependency libraries if the 1st degree dependency is included with a relative path. E.g. #include “…/…/TheLib/src/TheLib.h”. But not for libraries from the lib path. E.g. #include <TheLib.h>. SCons seems a little inconsistent here. See: GitHub - g3rb3n/TestPIODeps

Would it be an idea to include the lib_deps of the libraries in the dependency finder? This would not solve it for every lib, but at least for the libs written with a platformio.ini.

It should include now. See

Adding an internal library to the lib_deps causes the warning:

“… has not been found in PlatformIO Registry. You can ignore this message, if … is a built-in library”

Is there a way to turn-off this specific warning? Preferably just for the libraries for which I have been warned before and am aware of?

is it acceptable for you to include the header file in your projects main source and remove it from lib_deps, as written above?

It could be. It’s not ideal. It would mean arbitrary includes of everything under lib.

I am creating a sort of broad starter template for a project with unit testing. Sort of like the unit testing examples, but with some additional things I’d like to have in bootstrapping a project. So, I was trying for a general solution.

If this is the recommended solution, then I suppose I will just put those includes in the main.cpp with a note as to why they are included. I guess this is better than getting those warnings.

Thanks.