Go Down

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

Stijnos

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?

pert

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:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format

I documented what I learned while testing the feature here:
https://forum.arduino.cc/index.php?topic=653746.msg4407422#msg4407422

Stijnos

Thanks,

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

pert

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" {}

Stijnos

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

Go Up