PlatformIO Community

Issues with library with deeper folder hierarchy


I’m currently having some issues with a rather large project I’m working on. My main library which is the core of the whole project is split into many files, which are partially located in two or even three folders deep within the directory tree. This is obviously giving me include errors because PIO doesn’t seem to look more than one level deep for include files.

My IDE is VSCode, the folder structure looks like in the attached screenshot:

main.cpp should include Core1.h which is in the main directory “MyCoreLib” of the library.
Core1.h in turn includes stuff from the directories “modules” and “includes” and files withing the “modules” folder (like Module1.h, Module1.cpp) include stuff from the folder “includes” which is nested even one level deeper.

lib_extra_dirs has been set to the path of the Libraries folder.

Currently there is no situation where I go one level up like using …/ and such, I’m always only going deeper in the hierarchy when including stuff. Also, the library never includes stuff from “Project1”, obviously. However, Project1 might have to include stuff from the library’s “Includes” folder, deep down in the structure.

How is this done with PIO, or what would be another solution to this? I would prefer to NOT have all files in one folder as that would get messy and confusing very quickly, looking at the amount of files.

PS: just to maybe put more clarity into this, the library has multiple “Core1, Core2, Core3, …” cpp and h files because each of those core files implements different functionality composed from the modules in the “Modules” folder. A project like “Project1” in this example, will always include only one of the “Core1, …” .h files. Project2 might include Core2.h and so on.

edit2: maybe set lib_ldf_mode to deep or even deep+ would help? although the manual says this is generally not recommended…

Thanks for your help!

any ideas, anyone? i really don’t know how to proceed from here…

oh my god, figured a way out, usink hard links in the filesystem.

that LDF is just a monsterious, steaming pile of dog turd. the fact that it is processing and compiling every single h and cpp file within library folders regardless of whether the h files are included anywhere, is just plain BS, seriously.

why is that thing so utterly stupid and why doesn’t any of the ldf modes offer proper standard functionality of how files are included and processed, just like ANY other serious IDE is doing it? for gods sake, please ONLY include and process h files which were included somewhere. thank you.


edit: oh, yeah i had to put everything in folders which were directly beneath the lib folder. there are now all my files, without any additional subfolders. and don’t you dare putting something in a folder which you don’t want to compile in every project which uses one file from that folder.