5 years, 1 month ago.

Include .a file during compilation

Hi there,

I have a library that's been compiled into a .a file that I need to include in a program. The library has been specifically compiled for a Cortex M0+ and I am using an STM32 L073RZ which uses this processor. Simply put, my question is: How do I use the mbed-cli tools to include this file when compiling?

Thanks, Adam

1 Answer

5 years, 1 month ago.

Hello Adam,

You can find an example in Mbed OS documantation at Compiling static libraries, 2. Compile multiple applications or tests against the static library.

  • Copy the header file associated with the library to your project's folder and #include it into the main.cpp file
  • Open a command prompt in your project's folder.
  • Issue the following command:

mbed compile -t GCC_ARM -m NUCLEO_L073RZ --source=. --source=[relative path from your project folder to the folder that contains the .a file]

Accepted Answer