Creating a shared library/archive

Hi All

I have a couple of source files that I want to compile and add to a library. I will then use this library in other projects. The files compile okay, but then platformio tries to link using ld.exe. I want platformio to instead call ar.exe. How do I get plaformio to do this?

Thanks, Richard

ps adding “build_flags = -Wl,-shared” into platormio.ini doesn’t work as avr/ld.exe doesn’t support the -shared option

You need Redirecting...

So, create somewhere a library which you would like to use with other projects and add ROOT folder where this library is located to lib_extra_dirs option in platformio.ini.

Ah, I get it now. platformio doesn’t link a library into the build, it creates all objects from source in the lib directory of the project. The lib-extra-dir extends the lib directory in your project to other directories that are outside of the project.