Skip to content

Why libtool runs ranlib for a static library installation?

I’m trying to understand why libtool runs ranlib when installing a static library. This is an example from the link:

$ libtool --mode=install cp /usr/local/lib/
cp /usr/local/lib/
cp .libs/libhello.a /usr/local/lib/libhello.a
ranlib /usr/local/lib/libhello.a

But, isn’t the index table already created and shouldn’t it be just a simple copy operation? I found running ranlib at the end of the copy redundant as the library already has an index.




Back in the bad old days, ar did not create an index.

libtool is intended to run on a variety of systems, some of which have an index-creating ar and some don’t.

For compatibility’s sake, it still invokes ranlib to create the index after installing the static library.