Can't find lib headers when using cpp files

I’ve got a project where I’m using the OneWire library which I installed using the Library Manager.

When I include <OneWire.h> in an ino file it works fine, but if I include <OneWire.h> in a .h or .cpp file it works when I first open the IDE, but if I change a single line of code and save it, it reports:

OneWire.h: No such file or directory.

Is there some sort of special config I need to do to let they the cpp compiler know where the files in the .pioenvs are located or is it necessary to use ino files for everything?

  1. Have you used PlatformIO IDE Terminal to install this library?
  2. What is your OS?
  3. Try Menu: PlatformIO > Rebuild C/C++ Project Index

P.S: I’ve just played with the project and can’t reproduce this error.


Thanks for the quick response. I used the Library Manager terminal from the IDE and I’m using a Windows 10 machine.

“Rebuilding C/C++ Project Index” seems to have made that error go away, though I’m still unsettled by the fact that when I build I get a green check mark next to PlatformIO:Build and the targets get updated, but I still have lots of GCC warnings and errors displayed in the IDE and they don’t seem to ever go away I unless I close the IDE and restart it.

Could you share on the content of .gcc-flags.json file which is located in the project?

Here is the paste of the .gcc-flags.json