PlatformIO Community

Develop Lib and App in parallel - how to update automatically


at first thanks for this amazing tool, it eases up firmware development so much.

Currently I stumble accross the following issue:

  • I write my application code in ./src
  • in parallel I need to bring up a library that is in ./MyLib
  • I managed to get the build running and I see with pio run -v that MyLib goes to .piolibdeps and is compiled nicely to libMyLib.a and linked properly to the appcode forming a valid firmware.elf.

Now, what I want to achieve is that,

  • if there is a change in ./MyLib/foo.h (or any other fike), I want to get an update of .piolibdeps/MyLib and build it with the modified code.
  • I need a solution without any extra loop like changing version in library.json, erase .piolibdeps, commit and push/pull the change
  • I really would appreciate a clean solution without messing up things in PIO or SCONS.

Is there any good practice to achieve this. could help extra_scripts in platformio.ini.

Best Regards, Axel.

1 Like

I continued checking for a solution.

I found this older post Library Development HowTo

I have now the following files:


description = PIO Example
includes = -IFooLib
cpu_flags =  -Os -g  --specs=nosys.specs -flto -ffreestanding -nostdlib -L. -T./ -Xlinker 
defines = -DFW_VERSION=v0.0.1

platform = atmelsam
board = MyBoard
build_flags = ${common.cpu_flags} ${common.includes} ${common.defines} 
#lib_deps = file://./FooLib
lib_extra_dirs = ./FooLib


  "name": "FooLib",
  "keywords": "foo fooFast",
  "description": "fullblown FOO implementation without BAR",
  "version" : "0.0.1",
  "platforms": "atmelsam",
  "build": {
    "flags" : ["-DLIB_WITH_FOO_A"]

With just lib_extra_dirs it use modified files from ./FooLib/src but it ignores the “-D-values” set in library.json.

If lib_deps = file://./FooLib is enabled, it copies the sources into .piolibdeps once but ignores any further updates in FooLib/src

What can I do, that values in FooLib/library.json are used without lib_deps?

Thanks for listening, I figured it out :slight_smile:, there are two modes:

To do the development locally, lib_extra_dirs and having all compile time switches in platformio.ini are completely sufficient.

lib_deps and library.json belong to published libraries that pulled from a repo, even a local directory. library.json is written after the implementation is complete/basically working for consumers/users that simply wants to use the library (it is a manifest of the library). Users also use lib_deps in their platformio.ini.

To have user and developper in one platformio.ini there can be used probably different [envs].

One more finding:

The flag lib_extra_dirs is a pointer to a top level directory. If the dir. has the structure

+ platformio.ini
+ libraries/
    + FooLib/
        + library.json
        + src/
   + BarLib/
        + library.json
        + src/

then also the build settings in the library.json files are used.

1 Like

If you don’t like a default name for project libraries storage, you can rename it via