开发者

large c++ static library file after linking

I am building a library from my source code which contain both header (.hpp) and source (.cpp) files. I have a make file which compiles all the source files into respective object file individually and then a library creation (ar rcs ..) statements which combines all the *.o files and builds a static library out of it. T开发者_Python百科he resulting size of the library file is huge (around 17 Mb). Instead when I do g++ -o a.out *.cpp the out file has a size of 1.4 Mb. Is the archiver command (ar rcs) not removing redundant information from all the individual object files ? I also created shared objects and those were small as well, but I need a static library file for my purpose


Try strip the library, the debug and symbol information and tables might take the extra space.

Also, the ar s option might inflate the resulting archive (again, strip, or just don't use ar rcs, just ar rc).


What happens when you link your static library into a final binary? There's a lot of extra data that should get stripped out during the link process into a binary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜