Compiling and using a static library

Hi everyone,

To improve the compilation time for a project of mine, I was wondering how to get a pre-compiled library that I wish to use and how to include it in my build.

So far, I have found this as the only official guide on how to use precompiled libraries.

But my question is how to get the .a and the .o files in the first place? On StackOverflow, I stumbled upon this question, and the advice is as follows:

  • put "dot_a_linkage=true" in the library.properties file
  • copy the .a file for the library from the Arduino temporary build files
  • place it in "[library]src/[platform] and set the library.properties to "precompiled=true" and "ldflags =l[library]

However this doesn't seem to work for me, because I cannot get the compiled .a file to appear in my build files.
Is this maybe happening because of a change of the dot_a_linking parameter in library.properties?

I am using Arduino 1.8.11 and the library I'm trying to precompile is Bodmer's TFT_eSPI library.

1 Like

I documented how to use the precompiled library feature here:
https://forum.arduino.cc/index.php?topic=653746.msg4407422#msg4407422

Give that a read to see whether it answers your question.

1 Like

Okay, going through your forum post assured me that I was on the right track.

However, I'm still having some issues.

I'm compiling the library for the esp32 platform so I copied the *.a file to [library]/src/esp32/lib[library].a
I've made changes to the library.properties and set the precompiled=true and removed the dot_a_linkage=true line.

But my library is still compiling from scratch on the 1st compilation. To confirm that something was off, I deleted the main .cpp file in the library and that resulted in a compilation error.

It seems the .a file in [library]/src/esp32/ isn't used at all.
Do you have any clue as to why this occurs?

Ok, the issue seems to be gone when I updated to the new 1.8.12 version (released yesterday).

I've also asked for help in the Arduino GitHub issues section, in case someone finds it useful.

1 Like