Turn thin archive to regular

I create V8 , and by default it builds as a “thin” archive, where .a files essentially just contain pointers to object files in your file system, and not to the object files themselves. See man ar for more details.

I want this library to be located in a central place so that other people can link to it, and it would be much easier to provide a normal archive file rather than provide a flock of object files.

How to take the thin archives created by the assembly and turn them into regular ones? I assume that it will be as simple as listing the object files in a thin archive and rebuilding the archive using them, but I don’t know which command can be used to display archived object files.

+6
source share
1 answer

After some additional research, ar -t can be used to list object files in an archive, so after that it’s just a matter of providing this list ar , as you usually did when creating the archive.

The following script handled this for all libraries simultaneously:

 for lib in `find -name '*.a'`; do ar -t $lib | xargs ar rvs $lib.new && mv -v $lib.new $lib; done 
+17
source

Source: https://habr.com/ru/post/974505/


All Articles