PlatformIO Community

Can't get "lib_dir" working

I’ve set up exactly the same example as in the documentation for “lib_dir”:
“PlatformIO will find your libraries automatically, configure the preprocessor’s include paths and build them.”
No, it doesn’t. Neither the include files are found, nor the *.cpp files are compiled.
But “include_dir = …” works, then the include files are found and “src_dir” works as well, then the library files are found, but of course not “main.cpp”.
What’s wrong with my setup ?
Hope you can help

Additionally I’ve tried to change lib_ldf_mode to deep
all the parameters are simply ignored --> it can’t be that such a simply requirement doesn’t work ???

So you mean this example?

What main.cpp? The example references main.c.

Do you have your project uploaded to Github for reproduction of the problem? Or a more precise error message and project setup structure?

I have the same problem, when I set the lib_dir to specify my libraries, PlatformIO cannot find any header file in the libraries.

Are you sure you don’t want lib_deps or lib_extra_dirs?

Sure, I put the source code(.cpp and .h) in a directory named mylib, my project directory structure like this:
I config the option: lib_dir=mylib
Then I include mylib header file(#include “yCard.h”) in main.c,but it report error:no such file when i compile the project.

This is absolutely working.

Scanning dependencies...
Dependency Graph
|-- <common>
Building in release mode
Compiling .pio\build\uno\src\main.cpp.o
Checking size .pio\build\uno\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.8% (used 200 bytes from 2048 bytes)
Flash: [=         ]   5.1% (used 1634 bytes from 32256 bytes)
Building .pio\build\uno\firmware.hex
==================[SUCCESS] Took 2.06 seconds ==================

Thank you for your reply!
Could you send me a copy of your experimental source code for reference

It was right there in the topic

Thank you very much!