Had two arduino projects and had to load the libraries in each. Is there a SIMPLE way to load a library so both projects would see them, the way arduino IDE does?
Sort of, yes. But it isn’t recommended. Global libraries are a thing of the past as they have caused numerous problems. However…
- Create a folder, I’m assuming Windows, call it
C:\pio_libs
. - In
C:\pio_libs
, create a library folder for your common library. - You can create
src
andinclude
in the new folder but not mandatory. - Copy your library’s source code into the library folder, or into
src
andinclude
. - Edit
platformio.ini
and addlib_extra_dirs=c:\pio_libs
. - Edit
platformio.ini
and remove the library name(s) fromlib_deps=...
. - Edit the projects source code to ensure you have
#include "library_header.h"
as appropriate for the library. - Build.
lib_extra_dirs
and folders beneath will be searched and used as required.
HTH
Cheers,
Norm.
Thank you Norm
Cheers
Joe
1 Like