Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release LIB is huge compared to debug

Tags:

visual-c++

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?

like image 398
Mr. Boy Avatar asked Jan 12 '10 20:01

Mr. Boy


5 Answers

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.

like image 153
karoberts Avatar answered Nov 20 '22 17:11

karoberts


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

like image 27
rost Avatar answered Nov 20 '22 17:11

rost


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.

like image 21
Terry Mahaffey Avatar answered Nov 20 '22 18:11

Terry Mahaffey


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

like image 29
dicroce Avatar answered Nov 20 '22 18:11

dicroce


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.

like image 1
Ashish Avatar answered Nov 20 '22 17:11

Ashish