Organize libaries

Hi Im new in PlatformIO,
I have about 30 libraries which I wrote for my own usage. How can I install them locally in PlatformIO to easliy use them in different projects, update etc ?

thanks in advance!

To use own libs globally please place them to ~/.platformio/lib folder. If you don’t see this folder, just install some library, for example, pio lib install 1.

thanks, how do You advice to manage all these libraries ?
Should I create one project which include all of them?

I have added my libary to path You specified but still cant see that under lib of project.

~/PlatformIO/Tests/Test1$ pio lib install MemoryVariables
Usage: pio lib install [OPTIONS] [LIBRARY_ID]

Error: Invalid value for “libid”: MemoryVariables is not a valid integer
:~/PlatformIO/Tests/Test1$ pio lib install 1
Installing library [ 1 ]:
Downloading…
Unpacking…
The library #1 ‘OneWire’ has been successfully installed!

I’m looking for solution where I can easily manage/develop/update these libs

You can keep own libraries in the own location. Then just make the symbolic links to them. For example,

ln -s /path/to/you/testLib ~/.platformio/lib/testLib

Then in sketch use

#include <testLib.h>

where testLib.h is located in /path/to/you/testLib folder. PlatformIO will automatically include your library to the project and build it. See detailed docs about library structures.

thanks - and what about developing these libraries - what do You advice here?
Should I create separate project for each lib or create one project where all sources are attached ?

ps - link to library works its being automatically attached but I cant see that library under project lib

Here are a lot of options. If these libs are not linked and have a different context, then I don’t recommend to use “single project” for all libs.

PlatformIO has interesting shortcut platformio ci. You can create examples folder for each library and place here different examples. Then test them as pio ci /path/to/lib/examples/myexample/test.cpp --board uno.

Another way is to create PlatformIO Project (pio init) and use these libs in the practice.

This is OK. Project’s lib folder is intended for “private/project’s specific” libraries. You have asked me before “how to put all my libs into the global scope”. ~/.platformio/lib is global scope.

I like PlatformIO project a lot!

  • thanks for advices
1 Like

Happy Coding with PlatformIO! :wink: