How to create common source folder?

I’m attempting to create a common source folder that is used across multiple projects. I tried the lib_extra_dirs command, but I don’t understand how the project folder needs to be setup for platformio to properly detect it. In particular, I see this warning about that command:

This is a not direct path to a library with source code. It should be a path to storage that contains libraries grouped by folders. For example, D:\PlatformIO\extra\libraries but not D:\PlatformIO\extra\libraries\FooLibrary .

I do want to link directly to a library with source code, so probably this isn’t the correct option. The other method I’ve seen suggested is to update the build_flags w/ the the necessary include paths. Unfortunately, while the headers are now resolved, this still doesn’t work as platformio doesn’t build the .c and .cpp files and I’m not certain how to tell it about an additional src folder.

Can someone please help direct me as to the proper method to accomplish this?

Hey, did you find any solution for the problem? I’m facing the same situation and wasn’t sure how the solve this.

Are these actual libraries? As if that’s the case, you should be able to have a folder (lets call it root), and in that folder, have folders for each of the libraries. You then use lib_extra_dirs to point to that root folder, and if one of these libraries is referenced in your code, it’ll be found.

Yeah, so actually these header file aren’t a actually library. But I think I don’t have another choice than making them to a library linking them with lib_extra_dirs.

1 Like

If they are headers, you should be able to add to them to the include path (at which point you do need to use the folder containing the headers). See the -Idir option for build_flags