开发者

Release LIB is huge compared to debug

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 sh开发者_高级运维ould 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.


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


No, this is not normal. It should be the other way around. Yes, you should care.

I'd start by looking at the sizes again, to make sure I didn't transpose the release and debug sizes somehow.

Then look at the libraries you're linking in for release and debug. Did you accidentially link a debug library to ship, and ship library to debug?

Take a close look at your settings for release and debug. Something very fishy is going on.


Is it possible that a massive amount of this code is inline, and the debug version isn't "inlining"?


Ideally release lib should be smaller than debug one.

I guess you may be statically linking other libs such as MFC ,ATL etc...

check you release and debug build setting.

use #pragma once to avoid multiple time file inclusion.


I would typically expect the reverse...

Is it possible that there are big swaths of code inside preprocessor included blocks that only get included in release builds?

Template code is especially suspect in this case.

Update

I think that the issue is most likely caused by linking to static libs in release mode, and shared libs in debug mode...

+1 karoberts


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?)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜