How to merge 2 .a libraries to one .a library on Linux?

We have 2 static .a libraries and we would like to merge them into a single one for easier usage.

How to merge 2 .a libraries to one .a library on Linux?

asked May 19, 2015 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

With GNU ar, you can specify the single command-line option -M and control it with a script supplied via standard input, like the MRI "librarian" program, beside of controlling ar's activity using command-line options.

You can use this command to merge 2 .a libraries, say ezm.a and libformat.a, to a single .a library, say libezm.a:

ar -M <build-lib.mri

The build-lib.mri is as follows.

create libezm.a
addlib ezm.a
addlib cppformat/build/libformat.a
save
end
answered May 23, 2015 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...