Definitive way to Manage Private Libraries?

Is there an uptodate documentaion or tutorial on the definitive way to store private libs and share with all my projects. There seems to be so many confilicting advice on the forum ans im not sure what is the best method.

I have tried lib_extra_dirs which i note is depreciated. i have tried Symbolic link lib_deps = FooLib=symlink://../../shared-libraries/FooLib but non are working.

At the moment all i want to do is set up a project config template which i can share with all my projects.

ProjConfig.h and ProjConfig.cpp

It shouldnt be this hard.
A tutorial with all the pit falls would be awesome.

Cheers

1 Like

This is the only valid approach and it should work. Could you provide a simple project to reproduce the issue?

I can but befor i do that a simple question on the syntax. To link to a private library on my machine would i use.

ProjConfig=symlink:file:///C:/Users/bucko/OneDrive/aElectronics/uP/Libraries/PH7/ProjConfig

or

ProjConfig=symlink:///C:/Users/bucko/OneDrive/aElectronics/uP/Libraries/PH7/ProjConfig

When i use

lib_deps = ProjConfig=symlink:file:///C:/Users/bucko/OneDrive/aElectronics/uP/Libraries/PH7/ProjConfig

i get

Resolving portenta_h7_m7 dependencies...
Library Manager: Installing symlink:file:///C:/Users/bucko/OneDrive/aElectronics/uP/Libraries/PH7/ProjConfig
Error: VCS: Unknown repository type symlink:file:///C:/Users/bucko/OneDrive/aElectronics/uP/Libraries/PH7/ProjConfig

when i use

ProjConfig=symlink://C:/Users/bucko/OneDrive/aElectronics/uP/Libraries/PH7/ProjConfig

i get

Resolving portenta_h7_m7 dependencies...
Already up-to-date.
Updating metadata for the vscode IDE...
Project has been successfully updated!

but my complie fails with

src\main.cpp:6:10: fatal error: ProjConfig.h: No such file or directory

********************************************************************
* Looking for ProjConfig.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:ProjConfig.h"
* Web  > https://registry.platformio.org/search?q=header:ProjConfig.h
*
********************************************************************

 #include "ProjConfig.h"
          ^~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\portenta_h7_m7\src\main.cpp.o] Error 1

Ok ihave got it to work but still believe a turotial is needed. There is quite a few pit falls and gotchas.

This is what I did.:

  1. I set a up a folder structure as follows: C:\MyLibs\TestLib

  2. In folder TestLib i placed header and source files. TestLib.h and TestLib.cpp

  3. In my project platfomio.ini lib_deps section i added.
    TestLib=symlink://C:/MyLibs/TestLib

  4. (Note the syntax, they are forward slashes. Tip, get the directory path out of your browser).

  5. Now Build and you will most likley get this error.

Processing portenta_h7_m7 (platform: ststm32; board: portenta_h7_m7; framework: arduino) Error: Could not find one of 'library.json, library.properties, module.json' manifest files in the package

  1. This is because you need a manifest file in the folder as well. i grabed library.properties from another library package file then put it into my TestLib folder, and edited as follows.
    (BTW: is this a bad thing to do? will it cause futher problems? please let me know).
name=TestLib
version=1.0.1
author=Bucko
maintainer=Bucko
sentence=Buckos ST32M Configfile
paragraph=
category=Other
url=
architectures=mbed,mbed_portenta
includes=TestLib.h
  1. Then i Clean then Build again and it worked. here is my explorer view. (note: MyLibs folder dosn’t need to be added to the project. i have it added to edit easily).

image

Futher Tips:

  1. You will need to add a new folder for each Library you want plus add a library.properties

  1. For each library you want to include you will need to add it to lib_deps

  2. If you have done this perfectly and keep getting
    Error: Could not find one of 'library.json, library.properties, module.json' manifest files in the package
    the only way i could find to fix this was edit .pio\libdeps\portenta_h7_m7\TestLib.pio-link
    for some reason it kept getting stuck here.

  1. Another Gotcha is the Header file must start with a capital TestLib.h not testLib.h (i found this out the hard way.

You don’t need to add library.properties. The library.json is enough.

This is the issue with Windows and its “case-insensitive” file system.