PlatformIO Community

Cannot include files, error No such file or directory

VS will not compile the program below, I get error “src/main.cpp:7:22: fatal error: TestLib1.h: No such file or directory”.

If I comment out TestLib1.h (or any other TestLib) it works.
If I, on the other hand, comment out only AsyncElegantOTA.h it fails with same error.
And, if I comment out only DallasTemperature.h it fails with same error.

The TestLib files are the same except for the numbers (1 to 7).

The program and TestLib are obviously stripped of any useful code only to show the problem and hopefully make it easier to reproduce the error.


#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>
#include <DallasTemperature.h>

#include “TestLib1.h”
#include “TestLib2.h”
#include “TestLib3.h”
#include “TestLib4.h”
#include “TestLib5.h”
#include “TestLib6.h”
#include “TestLib7.h”

void setup() {

void loop() {


platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
lib_extra_dirs = …\custom_lib
lib_deps =


#ifndef TESTLIB1_H
#define TESTLIB1_H

#include <Arduino.h>

class TestLib1 {
void tt1();
int tt=0;



#include “TestLib1.h”

void TestLib1::tt1() {

And where exactly is this file located?

Remember that per docs this folder must then contain additional libraries in their own folders, so, custom_lib\TestLib1\TestLib1.{.h, .cpp} etc.

1 Like

Thank you for looking at this.
The TestLib files are stored like this:
custom_lib\TestLib1\src\TestLib1.{.h, .cpp}
custom_lib\TestLib2\src\TestLib2.{.h, .cpp}
… and so forth.

Further, please note that if I comment out for instance AsyncElegantOTA.h then it compiles without errors.
It is almost like the combination of the “<>” includes prevents more than 6 other includes.

You need to lose the src part of the path.

All libraries like this should be, as @maxgerhardt mentioned above, stored in lib/libname/ where libname is the library name for each particular library, and all source and header files live together in that directory. There are no src or include sub-directories.

You need:

custom_lib\TestLib1\TestLib1.{.h, .cpp}
custom_lib\TestLib2\TestLib2.{.h, .cpp}



Ok, I will give it a try.
But, can you then explain why all 7 TestLib compiles just fine if I comment out this line:
#include <AsyncElegantOTA.h>
And also why it works if I comment out one or more of TestLib?

In a word, no! Sorry.

Interesting. Normally, the angle brackets are used when including “system” headers – those supplied by the compiler or the compiler/standard libraries. You would (should?) use double quotes for your own, or third party supplied library headers. I see a lot of people using either and it doesn’t usually matter. Strange.

Sorry I don’t have a definitive answer for you. Hopefully, the lib structure reorganise will help.


Thanks a lot.
Removing scr did it!
Thank you both for the help.
But, I could not resist adding scr to TestLib7, then 6, then 5 and all the way to TestLib1. And it works, even though I am back to square one. If I had hair I would grow grey ones :slight_smile:
Anyway, if I run into this problem again I will use your solution.

1 Like