Pre-compiled libraries in the sketch folder

Hey all,

I very often place my libraries as sub-folders in my sketch folder rather than using the typical Arduino library folder. So, for example, I may have a folder structure like this:

.\MySketch.ino
.\src\Adafruit_BME680\Adafruit_BME680.h
.\src\Adafruit_BME680\Adafruit_BME680.cpp

I do it this way for multiple reasons.

  1. I have found that each project I work on has different requirements, and so often times I may need to "tweak" the code of a library for a certain project. I like to keep those "tweaks" private to a specific project rather than having those code changes explode and affect other projects I am working on.

  2. I prefer to have all my code and all my dependencies fit into a single Github repository. In that way, I can easily just clone the repository and build. No need to install libraries on each and every development computer - because they are already in the repository as sub-folders of the sketch.

Anyway, I have recently been trying to use a library that includes a pre-compiled ".a" file, and I need to figure out how to get the ".a" file to link properly. The structure of the project is something like this:

.\MySketch.ino
.\src\my_precompiled_file.a

How can I get this file linked properly so I can use it?

If it matters: I am using a custom board definition, but it's pretty much the same as the Adafruit Grand Central M4 Express with a SAMD51 microcontroller (ARM Cortex M4).

Thanks!

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

You can specify that the compiled library be kept and reused in the library.properties file. If you put a .a file in the expected place it will use that instead of re-compiling the library sources.

Start reading this post at reply 14:

Sorry, maybe I did not explain my situation well-enough in my previous post. I am trying to do something quite different than what you described in your answer.

Most people who use Arduino have a library folder, as you know, and all their sketches just simply include libraries from that library folder. While that is useful in many situations, I have found that in my personal situation I like to have each of my sketches have its libraries private to itself. Therefore, rather than keep them in a pre-defined library folder, I place code in sub-directories to the sketch.

So my situation is not like this:

If it were like that, then there would be a library.properties file, and I would make sure it had all the settings properly set as you suggested from that other thread. But my situation isn't like that.

I have a simple ".a" file sitting a sub-directory of my sketch. That's it. It's not off in some library somewhere else. I want to make sure that the pre-compiled ".a" file in my subdirectory of my sketch can get linked into my binary, and right now I am just getting compile-time errors attempting to do this. Any suggestions?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.