Using the -Ldir build flag to specify a relative directory

Hey all!

On a project I’m working on I need to include a statically compiled library (libPDMFilter_GCC.a). As far as I’ve understood I should not place this in the /lib/ directory, so I’ve instead created some other directory, say lib_ext, and then added

build_flags = -lPDMFilter_GCC -Llib_ext

to the relevant platformio.ini file and regenerated the project. However, when compiling the project the actual command sent to the linker is


This issue seems to be isolated to specifications with a relative path, as using -L/home/....../lib_ext generates the expected output and cleanly compiles.

Any ideas as to how to resolve this issue? I’ve tried various combinations of surrounding the command with “” and ‘’ but to no effect.


  1. This is a bug. Please open an issue here Issues · platformio/platformio-core · GitHub and I’ll fix it.
  2. Temporary solution is to try one of these:
    • build_flags = -lPDMFilter_GCC -L$PROJECT_DIR/lib_ext
    • specify the full path to lib_ext directory

Thanks for the update, I’ve created a new issue now. Thanks!

Does something work from the solutions above?

Yes, both of the specified ideas above worked, though the first is by far the better as it allows for a relative path. Thanks!