Arduino Forum

Development => Suggestions for the Arduino Project => Topic started by: lululuv1 on Mar 29, 2019, 02:49 pm

Title: Lock using static libraries *.a
Post by: lululuv1 on Mar 29, 2019, 02:49 pm

I would like to link a static library into my Arduino project. I have tested it for SAMD and AVR respectively ( Arduino Uno et Arduino Zero)

I have already read this topics: ( ( (

I follow the instruction in order to add static library, then I can see it in the Contributed library (attached file)

Here is the source code of my compiled library :
Code: [Select]
int foo(void) {
  return 1;

Then, I create a library using ar tool.

I create a repo called foo which include
* and a repo src as below:

Code: [Select]

maintainer=foo <>                                                                          

My foo.h contain the function prototype : int foo(void);

FInally I create the ino project, include the library....

Code: [Select]

#include <foo.h>

void setup() {


void loop() {
  int foo_value = foo();

Link with the library is done because if I want to link a libfoo.a from a dismatch architecture I got an error.

Hence, there is no compilation error, no link error but when i call the function foo(); I am lock, the print FOOFOOFOOFOO is never done.

Any idea ?

Thank you
PS: this is a simple example in order to reproduce the problem, can be done with avr-gcc or arm-none-eabi-gcc
Title: Re: Lock using static libraries *.a
Post by: mhmayyan on Mar 10, 2020, 06:05 am
It works for me when I do not use the prefix lib