I have the Folowing dir stracture:
// Code Code Code
// Code Code Code
I am getting the Error:
In file included from lib\mylib\mylib.cpp:1:0:
lib\mylib\mylib.hpp:11:24: fatal error: foo.h: No such file or directory
The only way I found around it is to put a full path in the #include statement inside “mylib.hpp”
Stab in the dark here, does setting
lib_ldf_mode = chain+
platformio.ini fix it? If it does, read here to find out more about what that flag does.
Also triad deep/deep+
VS Code Intelisense don’t show errors.
It’s just when I try to compile.
Eyes are glazing over, so I’ll look in the morning, unless someone else jumps in in the meantime
Isn’t the build system such that libraries are compiled in isolation?
If so, they can only access their source code plus the code of their own dependencies. They see neither the code of the main project nor of sibling or parent libraries.
So they way to inject configuration data from the main project into libraries is to use defines in the
(The ESP-IDF framework is an exception. The
sdkconfig.h file from the main project is available to all libraries.)
The problem is that I have the same dependency both in the main.cpp code and in some of the libraries that I created.
For example a typedef that is defined in \include\my_types.h .
in the main source file, every thing is fine and I can write:
but in a library I created, \lib\mylib\mylib.hpp ,
I must put a full path, “c:\Users…Projects\myProject\include\my_types.h”
Or I am getting the before mentiond error during build time.
Clearly your library depends on the main project. I don’t think that’s supported. Usually it’s the other way round.
Either move the
typedef into the library or integrate all the library’s source code directly into the main project.
The idea behind creating this libraries is to do some code refractoring and not have every thing in the main project file.
There is no reason that I shuld not be able to include a header file from the “include” folder into a library that is in the “lib” folder.
so is there a solution for this one?
Your intention to do code refactoring is good. However, the result is strange. The main project depends on the shared code and the shared code depends on the main project. Such cyclic dependencies are not supported by the library concept of PlatformIO as far as I can tell.
There is even a software metric for it: cyclomatic complexity. The higher this metric is, the lower is the software quality. There are tools to anlyze it so you can lower it and improve the software quality.
I strongly suggest you refactor your code such that the shared code does not depend on the main project. The code will be less complex and fully supported by PlatformIO.