I have a static library project with standard debug/release build options. I was intrigued to spot that while the debug .lib is a fairly large 22Mb, the release one is a whopping 100Mb. And this is not a massive code-base either, about 75 classes and none of them very giant.
My questions are whether this is normal, and whether I should care?
I would check to see if you're statically linking libraries in release mode and dynamically linking them in debug mode. You might be statically linking the C++ runtime for instance.
Assuming he is asking about a static library project, the static library is not ever linked with anything in the project. Linkage of static libraries only occurs whren the library is used. –
anonJan 12 '10 at 21:00
Correct Neil. No linking here, only external #includes –
Mr. BoyJan 12 '10 at 21:18
I had the same problem. The fix is very simple. Project Property/Configuration properties/General/Whole Program Optimization use No Whole Program Optimization instead of Use Link Time Code Generation. Size of my static library decreased from 5MB to 1.3MB
Not sure why, but this was the reason for me. It should not really be an issue unless you are deploying the .lib files somewhere. If you're just keeping them local to your solution, you should be alright because the .exe or .dll file that consumes the static lib will eliminate the stuff it doesn't need. My question: stackoverflow.com/questions/2472568/… –
CuppMMar 23 '10 at 16:30
Template code is blown out inline in Debug builds just like Release, so that is not likely to be the problem here. –
John DiblingJan 12 '10 at 20:40
Agreed, unless it's in a #if RELEASE or similar case. –
John WeldonJan 12 '10 at 20:40
I don't think so; a release compiler/optimizing can fold together template code to next to nothing. This is a huge size difference. –
Terry MahaffeyJan 12 '10 at 20:40
There is one thing that can explain such a size: debug symbols embedded in the release build (as opposed to built as a pdb). Are you sure you don't have debug symbols being generated for your release build ? (which visual c++ are you using?)
2008. PDB/debug info is an area I plan to look at closely... I generally do generate PDB for release & debug, but that should be a separate file. –
Mr. BoyJan 12 '10 at 21:19
ok. culprit might be /Z7 and/or /Yd if using pch files. You might want to provide all the options you're using on your command line. –
BahbarJan 12 '10 at 21:35