It is possible to use pre-compiled libraries in the Arduino IDE. See the documentation of the "precompiled" field of library.propertied here for details:https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format
I have never used this feature, but I believe there is some information on how to use it buried in an issue report in one of Arduino's GitHub repositories. I was looking for it when I found the issue I described above. I can continue looking and probably find it, but I thought I would check with you to see if you're still interested. It may be that requiring the users of your library to find the platform.txt file associated with the board they're compiling for and modify to make the precompiled feature work will not be feasible. That would depend on who the target users are. So let me know what you think.
So as I understood I need to create a .a file for each of the targets I intend to use. Then create a library that includes those .a files. And finally modifying each of the platform.txt for each of the targets I intend to use.
This sounds ok until the last part, because if you update the IDE, you'll need to redo all.
But there are some steps in the way of creating those .a files that I don't fully understand. How do I compile the library from the command line or in a makefile if it makes use of the Arduino.h Library? , How do I link the Arduino Library to the precompiled chunks I intend to make?
What would you recommend on doing?
This means there are currently 144 files involved, when building for Arduino I have to manually copy each file from the library directory, to a new directory so all of the files are on the same directory so Arduino ide can find them when compiling. This becomes pretty annoying when debugging code.
What should I do if there is some functionality I'd like to share, but for n amount of reasons I can't release the source code?
"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-size" -A "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_build_602003/PrecompiledTest.ino.elf"
"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_build_602003/PrecompiledTest.ino.elf" "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_build_602003\\sketch\\PrecompiledTest.ino.cpp.o" "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_build_602003\\libraries\\PrecompiledTest\\PrecompiledTest.a" "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_build_602003/..\\arduino_cache_483105\\core\\core_arduino_avr_mega_cpu_atmega2560_99b4804b5450ac10a663b47fdad40a36.a" "-LC:\\Users\\per\\AppData\\Local\\Temp\\arduino_build_602003" -lm
For the most part you are out of luck as most of the time it isn't possible.If that is the real reason for trying to move to pre-compiled code, then you will have to very carefully study the various licenses involved of all the code being used to create the final image (not just your code) because in many if not most cases, it is not possible to have some source be closed do to licensing restrictions of other code being used and/or build tool issues, particularly in the Arduino environment.For example, even though LGPL will allow creating a work that links in pre-compiled objects that use closed sources, it does require than any LGPL code that is used be updateable by the user.This means that the user must be able replace/modify/change any LGPL code that is used in the work and rebuild the work.i.e. he must have enough information and tools to be able to rebuild the f/w image and get the part updated with the new f/w.It also means that your pre-compiled objects can not contain any LGPL or GPL code.This is often very difficult to do as the code often uses header files and/or library code from the gcc tool set which is licensed LGPL or even GPL, including GPL 3.0 depending on which components are used.And then there is the possibility that while you may be able to technically comply with the LGPL licensing terms for your library, it becomes impossible for the end user to ever use the library because the only way to use the library is to link it with other LGPL or GPL based code to create the final image.This other LGPL or GPL code then creates licensing requirements for ALL the code in the image which includes your library and the end user may not be able to comply with the more stricter licensing terms so he legally can't create a f/w images that uses your library.An example of this might be that a closed library that ships pre-compiled objects depends on another library, and that other library is licensed as GPL 3.0GPL 3.0 does not allow linking against any closed source code.In this case, while the closed source library distribution may technically be LGPL compliant, it is not GPL 3.0 compliant and therefore the closed source library is not usable since it is depending on another piece of code that is GPL 3.0 and GPL 3.0 does not allow being used with closed source.There are many things to take into consideration when trying to use closed source in an open source environment.--- bill