I never put much thought into the size difference between a static library and a dynamic library until I downloaded pre-built libraries of boost today. I found that the static libraries of boost are much much bigger than the dynamic libraries.
For example, the debug multi-threaded boost wave static library is 97.7 mb
in size while the same library, but dynamic, is only 1.4 mb
in size (including import library and dll)! That is a huge difference. Why is that?
Second question, if I statically link against, let's say, the wave
library. Does that mean my executable will balloon in size to more than 97.7 mb
?
The static libraries have the full debug symbol information in them. For DLLs that information would be in .pdb files (which I assume would be similar in size to the static libs).
When you link to the static lib, the symbol information will not be copied into the .exe - it will be placed in the .pdb file (if your build is configured to create a .pdb file). The .pdb file does not need to be distributed with the .exe, whether or not the .pdb is created.
In the pre-built library download I get from boostpro.com, I don't get .pdb files for the boost DLLs they provide. if you build the DLLs yourself, you'll probably get the .pdb files (though you might have to set some config option, for which I have no idea what the details are).
update:
Looks like I might be wrong about easily getting .pdb files for the boost DLLs. From http://comments.gmane.org/gmane.comp.lib.boost.build/23246:
> Is there an additional option that I can pass on the command line to > have the (correctly generated) PDB files also copied into the stage > directory?
Not at this time. You can only hack
tools/build/v2/tools/package.jam
to add<install-type>PDB
everywhere where<install-type>SHARED_LIB
or<install-type>STATIC_LIB
is now written.