title: Reducing the size of a very large static library in Release builds
body: <p>We are working under Windows 7/10 and Visual Studio 2015, coding with C++ plus Qt (and linking with a handful other external libraries). Our project is rather big - more than 1300 classes, LOCs in the hundreds of thousands.</p>
  
  <p>We now need to split up the project into a "core lib project" (to which our module test project links to) and a "main() project" (which also links with the lib project to produce the executable).</p>
  
  <p>The issue I've run into is that that library created from the "core lib project" is gigantic - at least in release mode. Our application (when built in its current single-project form) ends up being ~40MB in size. The Library hits ~4GB(!) and then something breaks, because linking fails; the object file directory has ~7GB worth of .obj in it. (In debug mode the situation is far tamer - the library and .obj file directory do not exceed ~350MB). I'd appreciate any tips to what could cause this kind of size inflation (especially since the final all measure meagre ~40MB) or how to curtail it...</p>
  
  <p>Update: I found the "culprit" for the inflated object file sizes - Visual Studio's "Full program optimization" - "link time code generation" (the option /LTCG) to be precise. I disabled LTCG and the object file size shrunk from 6.7GB total to 64MB total...</p>
  
  <p>That said, I have less hope to reduce the library size since the linker during the creation of the library can probably not yet determine what it can optimize away (unlike during the creation of the final executable).</p>