0

I know to make a library on arduino ide with source codes, but I cant send my source code to another users who want to use my lib.

So I need to make a library with precompiled=true info at library.properties. And I need to put my .a and .so files at src/{build.mcu} (in my case, src/avr/mylib.a and mylib.so).

But, where is that files (.a and .so)?!

Does the arduino compiler generate this files? If so, where? If dont, how compiler I need to use?

I found the .o file at appData\local\Temp\arduino_build_XXXX\libraries\mylib\

Thank you very much and sory about my english.

3 Answers 3

1

[library] = library name

1) edit the [library] library.properties file and add dot_a_linkage=true to the end ... (/home/name/Arduino/libraries/[library]/library.properties)

2) build the example ...

3) After the build is complete navigate to the build folder (In Linux it's located in the /tmp/arduino_build_xxxxxx folder) then copy the dot_a file from under library folder (libraries/[library].a) to the arduino library folder for the [library] library (/home/name/Arduino/libraries/[library]/src/esp8266/lib[library].a)

4) edit the [library] library library.properties file again and remove dot_a_linkage=true and add precompiled=true and ldflags=-l[library] to the end of the file ...

5) build the example ... this time it links to the dot_a file ...

0
  • Note: I have never done this with the Arduino IDE, so I don't know if the resultant file will be of any use to you.

A .a file (you don't want a .so file - that's a shared library that makes no sense on a platform without an OS) is merely an archive (ar archive, specifically) that contains one or more .o files.

You create one simply enough using:

avr-ar rcs myLib.a myLib.o

You will find the avr-ar program in the tools installation within your Arduino IDE somewhere.


As an aside, UECIDE (which I wrote) uses library files like these to cache its libraries and other compiled code. You can use UECIDE to directly grab a .a file for your library, which you would find in the cache folder of the UECIDE data folder (find it through the Help -> Debug menu).

0

Thank you Majenko!

But, the program is not avr-ar for me, I use the avr-gcc-ar.

After that, I must to dot_a_linkage=true in my library.properties and manually add mylib.a at AppData\Local\Temp\arduino_build_115676\libraries\mylib\

I dont know why, but this help for me.

I hope help other.

Best regards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.