I'm building V8, and by default it builds as a "thin" archive, where the .a
files essentially just contain pointers to the object files on your filesystem instead of containing the object files themselves. See man ar for details.
I want to be able to put this library in a central place so that other people can link to it, and it would be obviously much easier to provide a normal archive file instead of providing a gaggle of object files as well.
How do I take the thin archives produced by the build and turn them into normal ones? I assume it would be as simple as enumerating the object files in the thin archive and rebuilding an archive using those, but I don't know what command can be used to list the archive's object files.
After some additional research, ar -t
can be used to enumerate the object files in an archive, so after that it's just a matter of providing that list to ar
as you usually would when creating an archive.
The following script handled this for all of the libraries at once:
for lib in `find -name '*.a'`;
do ar -t $lib | xargs ar rvs $lib.new && mv -v $lib.new $lib;
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With