Go Down

Topic: Lock using static libraries *.a (Read 205 times) previous topic - next topic

lululuv1

Hello,

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:

https://arduino.stackexchange.com/questions/57891/how-to-use-a-precompiled-library-in-a-project-with-arduino-ide
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format
https://github.com/arduino/Arduino/issues/4336

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
* library.properties
* and a repo src as below:
-/src
---foo.h
---/{architecture_mcu_name}
-----libfoo.a

Code: [Select]

name=foo                                                                                                
version=0.0.1                                                                                            
author=lululuv1                                                                                            
maintainer=foo <foo@gmail.com>                                                                          
sentence=                                                                                                
paragraph=                                                                                              
category=Uncategorized                                                                                  
url=                                                                                                    
architectures=*                                                                                          
precompiled=true                                                                                        
ldflags=-lfoo


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() {
  Serial.begin(9600);

}

void loop() {
  int foo_value = foo();
  Serial.print("FOOFOOFOOFOOF");
}


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

Go Up