Hello, i need help.
My project is not compiling.
#include <preferences.h>
ends in fatal error: Preferences.h: No such file or directory
.
i have this project structre:
src —> main.ccp
lib —> rfm.cpp, rfm.h
i need the Preferences.h
inside ‘rfm.ccp’ so in included inside ‘Preferences.h’ and got the error when compiling.
but if i rightclick on
#include <preferences.h>
→ go to definition
i can see the libary file Preferences.h
I also can see Preferences.h & Preferences.c
under following paths:
C:\Users\xxx\.platformio\packages\framework-arduinoespressif32\libraries\Preferences
.
in.vscode/s_cpp_properties.json
under 'include path i can see the line:
“C:/Users/Christian/.platformio/packages/framework-arduinoespressif32/libraries/Preferences/src”,`
But the compiler/linker doesn’t find Preferences.h
.
When i insert Preferences.h
to the main.cpp, Preferences.h
will be found.
what do i wrong?
thanks to all
Your directory structure is incorrect.
The README
inside the lib
directory clearly states:
“The source code of each library should be placed in a an own separate directory …”
Admittedly, the wording is misleading. It should read:
“The source code for each library must be placed in an own separate directory.”
All you have to do is create a new directory (e.g. RFM
) within the lib
directory and move your library files there:
|--lib
| |
| |--RFM
| | |--rfm.h
| | |--rfm.cpp
See also the documentation lib_dir — PlatformIO latest documentation
the whole example offers 2 options.
But nevertheless i tried all possible combinations.
i have no idea,why it runs after time.but i run again in this error with next lib.
i open a new thread,with dedicate example.
Both Bar and Foo are located in separate directories below lib
.
The source code of Bar
is located one level deeper in a src
directory:
lib/Bar/src/Bar.c
lib/Bar/src/Bar.h
lib/Foo/Foo.c
lib/Foo/Foo.h
There are no
/lib/Foo.c
/lib/Foo.h