How to merge 2 .a libraries to one .a library on Linux?
Posted on In QAWe 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?
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