静态和动态(调试)库和影响最终的exe的大小差异 [英] Size difference between static and dynamic (debug) library and impact on final exe

查看:265
本文介绍了静态和动态(调试)库和影响最终的exe的大小差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有把过多考虑到一个静态库和动态库,直到我下载了升压pre-建库今天的大小差异。我发现,升压的静态库比动态库多大得多。

例如,调试多线程升压波静态库 97.7 MB 的大小,而同一个库,而是动态的,仅仅是 1.4 MB 尺寸(包括导入库和dll)!这是一个巨大的差异。 这是为什么?

第二个问题,如果我对静态链接,让我们说,在库。这是否意味着我的可执行文件将在规模膨胀到超过 97.7 MB 吗?


解决方案

静态库中都有完整的调试符号信息。对于DLL的信息将是.pdb文件(我假设将是大小的静态库类似)。

当您链接到静态库,符号信息不会被复制到.exe文件 - 它将被放置在.pdb文件(如果您的构建被配置为创建.pdb文件)。 .pdb文件并不需要与.exe文件分发,以.pdb是否被创建。

在pre-建库下载我从boostpro.com得到的,我没有得到.pdb文件为他们提供升压的DLL。如果你自己构建的DLL,你可能会得到.pdb文件(尽管你可能需要设置一些配置选项,因为我不知道的细节)。


更新:

看起来像我可能是错的很容易获得的.pdb文件进行升压的DLL。从 http://comments.gmane.org/gmane.comp.lib。 boost.build/23246


 >有没有办法,我可以在命令行上传递到一个额外的选项
>有(正确生成)PDB文件也复制到舞台
>目录?


  
  

不是在这个时候。你只能砍
  工具/建设/ V2 /工具/ package.jam
  添加<安装型> PDB 无处不在哪里
  <安装型> SHARED_LIB
  <安装型> STATIC_LIB
  写的。


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.

这篇关于静态和动态(调试)库和影响最终的exe的大小差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆