Why is my static library so huge?

后端 未结 1 1049
慢半拍i
慢半拍i 2021-01-04 22:47

I have a C++ compiled static library of about 15 classes and their member functions and stuff, and compiled, it\'s almost 14 megabytes. It links to Google\'s dense hash tabl

1条回答
  •  隐瞒了意图╮
    2021-01-04 23:21

    The static library is a considerably different format the finished binary; partially because it has quite a bit more information. Essentially, the static library acts like a ZIP of all the .obj files generated from your translation units. This allows the linker to throw out unused functions, and if you're using LTCG, it allows the inliner to make cross-module decisions and other such optimizations.

    Additionally, some compilation modes will embed the debugging symbols directly in the .lib, removing the need for separate .pdb files.

    Generally you shouldn't need to worry about static library size; the linker will throw out all the extra information when building the final executable.

    0 讨论(0)
提交回复
热议问题