How can i link precompiled libraries?

I want to precompiled a library and add it as an archive (.a file) to my repository of program code. So that when compiling the code the archive is used, not the source code of the library.

How can i do that?

See example

[env:specific_inclibs]
build_flags = -I/opt/include -L/opt/lib -lfoo

http://docs.platformio.org/en/latest/projectconf/section_env_build.html#build-flags

1 Like

thank you!
The compiler have find the .a library.but can’t recognize file format because i compiled this library by ubuntu.
so how to compile a library used by platformio? I find ar.exe in compile route,can i use it?

What target architecture do you have? You can’t use a .a library compiled for a x64 machine on a non-x64 microcontroller (i.e., any microcontroller)

my mcu is stm32,what compiler can compile libraries that STM32 can use?

You have to cross-compile for a Cortex M3 or M4(F) target with matching Soft/Hardfloat ABI settings, using arm-none-eabi-gcc/g++, depending on what exact “STM32” you have.

Have you written the library you wish to link with yourself?

I’ve tried to compile with arm-none-eabi-gcc. The library compiled well in platformio, but the program will die when run library function.
Could you give me a simple library to test?
Thank you very much.