Using archive file (libxyz.a) in a Library

84 views
Skip to first unread message

Victor Aprea

unread,
Oct 28, 2017, 8:01:11 PM10/28/17
to Arduino Developers
Hi everyone, 

I've got an opaque blob provided by the manufacturer of a sensor in the form of an archive generated by avr-gcc. I want to make an Arduino Library for this sensor. 

If I put the .a file in my library's src folder, alongside my class cpp and h files, will the avr-gcc linker auto-magically pick it up in the Arduino build process? 

Otherwise,  is there a declarative mechanism that I can use as a library author to inform the Arduino builder about the archive?

Cheers, 
Vic

Martino Facchin

unread,
Oct 30, 2017, 10:41:19 AM10/30/17
to devel...@arduino.cc
Hi Victor,
you can add a field reading `precompiled=true` in `library.properties`. Then, copy the archive under `src/$mcu` ($mcu must match the one provided by gcc/g++ -mmcu commandline flag) and the library will be linked in the final build. 
Please not that only arduino-builder 1.3.25 and upwards support this feature (the relevant commits are https://github.com/arduino/arduino-builder/commit/89d7d392ac3f5aba40af276750a2d8548c5365c7 and  https://github.com/arduino/arduino-builder/commit/d2ff99cdf9c798ca3b1acffaf88d47f23eca4199) so only recent IDEs will work.

Hope it helps!
M

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.

Victor Aprea

unread,
Oct 30, 2017, 11:48:04 AM10/30/17
to Arduino Developers
Martino,

Cool, does that mean I have to build my own Arduino library source as an archive that includes the vendor archive and _that_ is what goes under `srs/$mcu`, or can I include my own .h and .cpp files that reference functions in the vendor compiled library in the src folder by adding the precompiled=true flag to the library.properties? 

Kind Regards,
Vic

Victor Aprea // Wicked Device

Victor Aprea

unread,
Nov 2, 2017, 11:20:27 PM11/2/17
to Arduino Developers
Hi again,

If anyone on the list can point me to an existing library that is doing something like this, e.g. on GitHub, so that I might emulate it, I would be most grateful.

Kind Regards,
Vic

Victor Aprea // Wicked Device

Reply all
Reply to author
Forward
0 new messages