Why can't PlatformIO find header file main.h?

Compiling .pio/build/esp32dev/lib313/connectRadio/connectRadio.cpp.o
In file included from lib/changeRadio/changeRadio.cpp:2:0:
lib/changeRadio/changeRadio.h:10:19: fatal error: main.h: No such file or directory
PlatformIO just can’t find header main.h for the lib’s changeRadio and connectRadio; why is that?

Libraries have by default no access to the include/ folder of the project, since they are supposed to be self-contained pieces of code, only depending on headers in their own library folder. As for configuration files, there are of course exceptions.

You need to add

build_flags = -Iinclude/

to the platformio.ini (docs) to inject the compiler setting to add the include/ to the include directory search path.

1 Like