Visual C++ 9.0 (2008) Static Lib + Boost Library =

2019-08-15 17:27发布

问题:

I have a Visual Studio 2008 C++ project that outputs a static library and uses some functionality of the Boost Library. When I build the project in Debug configuration, the .lib file is 7.84 MB. When I build the project in Release configuration, the .lib file is 23.5 MB. !!!!

The only Boost headers I include are:

  • boost/function.hpp
  • boost/exception/all.hpp

Since this is a static library, I don't have any Boost library files specified to include, but somehow it's a ginormous output. When I use that static library in a test executable, the resulting .exe file is only 746 KB in Debug and 231 KB in Release.

The problem is that I have to create a "release" of the library to check into a different repository to be used by other projects. And I would prefer not to have to add 30 MB of files each time I update it. And if nothing else it really confuses me as to why the Release build is 3 times the size of the Debug.

Anyone have suggestions as to what I'm doing wrong?

Thanks, Matt

回答1:

Project + Properties, C/C++, Optimization, Whole Program Optimization = No. That at least ought to keep your Release build size from blowing up. I can't repro the debug library size, just the headers gives me a 111KB .lib.