Turn thin archive into normal one

孤街醉人 提交于 2019-12-30 04:46:26

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/25554621/turn-thin-archive-into-normal-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!