Skip to content

Build library to .a file, use multiple sketches with .a file #1473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RobMeades opened this issue Sep 27, 2021 · 2 comments
Open

Build library to .a file, use multiple sketches with .a file #1473

RobMeades opened this issue Sep 27, 2021 · 2 comments
Assignees
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@RobMeades
Copy link

RobMeades commented Sep 27, 2021

Moved here from this forum post.

Not sure if this is my lack of understanding, a [documentation] bug report or an enhancement request.

I would like to ask arduino-cli to:

a) build my library, for a given architecture, to a .a file,
b) build sketch x, linking it with the above .a file.
c) build sketch y, linking it with the above .a file.

I can see that the dot_a_linkage directive in the library file metadata will tell arduino-cli to build the library to an intermediate .a file but I can't see how I would tell arduino-cli to just build the library for me, so not build a whole sketch but just build the library. The reason I would like to do this as a distinct step is to make sure that the library is built in "its own" way, any conditional compilation is decided by the library builder, not by some random application.

And then, of course, how would I tell it to compile and then link a given sketch using that .a file rather than building the library from source (though I guess that might be automatic?)?

I understand that I could do all of this manually (e.g. using an empty .ino file for (a) and then copying the resulting library .a file somewhere or other), what I'm asking is whether arduino-cli can be told to perform these steps by itself; it is a perfectly normal/logical build operation to perform and it looks as though arduino-cli should be able to do it, I just can't figure out how.

I suppose that what I really want is a lib command which compiles the library for the given platform. Job done.

Environment

  • CLI version arduino-cli alpha Version: 0.19.0 Commit: 56419ecd Date: 2021-09-02T14:47:35Z
  • OS and platform: Windows 10 Pro 20H2
@RobMeades
Copy link
Author

RobMeades commented Sep 27, 2021

[Deleted comment about not being able to do this manually: I realised that the --libraries parameter to compile should be to the directory above the library file, so I was specifying:

--libraries c:\temp\_jenkins_work\libraries\ubxlib --libraries c:\temp\_jenkins_work\libraries\ubxlib_test

...which causes arduino-cli to dump the .o files for both libraries into the src directory of the build output and then NOT package them into .a files. If instead I specify:

--libraries c:\temp\_jenkins_work\libraries

...then it puts the .o files into library-named sub-directories of the build output (i.e. ubxlib and ubxlib_test) and does correctly package the .o files into .a files first].

It might be worth updating your excellent command-line help to say that the --libraries directive will recurse so only the root needs to be specified.

So I can do it myself but a dummy .ino file and a Python script are required to perform the build and then copy the .a file into the correct place, whereas I'd have thought arduino-cli could simply JFDI...?

@per1234 per1234 added topic: code Related to content of the project itself type: enhancement Proposed improvement labels Nov 19, 2021
@vChavezB
Copy link

vChavezB commented Dec 6, 2021

Interesting solution. In my case, I am using Cmake to use the arduino SDK to build the library and copy the archive file (.a).

I think this would be a nice feature for developers of Arduino libraries ;)

@FStefanni FStefanni mentioned this issue Nov 14, 2022
3 tasks
@umbynos umbynos added the topic: build-process Related to the sketch build process label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

5 participants