0

What is the easiest way to create static library .a from the object file .o and other static library .a? Is it possible to do without additional extraction of the object files from .a file?

1 Answers1

0

I think the easiest way is to use libtool. First you create your statics libraries (ar rc lib1.a a.o b.o ... z.o) and finaly merge all the libs with libtool -static -o final.a lib1.a lib2.a ... libx.a.

You can do it with ar but you have to extract all objects before adding them in the final library.

Pouet_forever
  • 121
  • 1
  • 7
  • Thank you for your answer, but libtool can be a little tricky sometimes. In my case it prints error message like: "libtool: unrecognized option `-static'". – Victor Signaevskyi May 10 '17 at 13:10
  • The command I posted works in OS X. `libtool` is different in linux, I didn't notice that. Here is the answer for your question : [link](http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one#23621751) – Pouet_forever May 10 '17 at 13:24