Go Down

Topic: compile sources as static lib and link them (Read 1 time) previous topic - next topic


I've made a product based on Arduino, but actually only for using the W5500 network lib. I've added my own libraries in separate cpp files.
I'm using Visual Micro as IDE.
My customer would like to be able to build the code at his place.
I don't want to give him the source code of my own developed libraries.

Is it in arduino possible to compile these CPP files of my own libs as a static library and link them with the compiled code that I will share with him?

In a normal C compiler this is not a big problem, but does the arduino compiler supports this?
And If so can anyone tell / help me how?


Using the Arduino IDE, you can do this by using the precompiled field of library.properties. I don't know whether that feature is supported by Visual Micor.

Details in the Arduino Library Specification:

I documented what I learned while testing the feature here:



but that's for arduino style libraries only I guess?
My libs, are mare external source files with ansi C only. no C++
So my project should link the implementation of these function just from precompiled object files or something like that


It's possible to use C libraries with Arduino. Arduino sketches are compiled as C++, so you need to wrap the C function declarations in extern "C" {}


Ok, but how can I compile those c library sources to a .a file and add that to the linker?

Go Up