库和可执行文件的大小 [英] Size of a library and the executable

查看:40
本文介绍了库和可执行文件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 上使用 MSVC 创建了一个静态库 *.lib.库的大小是 70KB.然后我有一个链接这个库的应用程序.但现在最终的可执行文件 (*.exe) 的大小为 29KB,小于库.我想知道的是:

I have a static library *.lib created using MSVC on windows. The size of library is say 70KB. Then I have an application which links this library. But now the size of the final executable (*.exe) is 29KB, less than the library. What i want to know is :

  1. 由于库是静态链接的,我认为它应该直接添加到可执行文件的大小,最终的 exe 大小应该不止于此?windows exe 格式是否也对二进制数据进行了一些压缩?

  1. Since the library is statically linked, I was thinking it should add directly to the executable size and the final exe size should be more than that? Does windows exe format also do some compression of the binary data?

Linux 系统如何,即 linux 上的库大小(*.a/*.la 文件)与 linux 可执行文件(*.out)的大小有何关系?

How is it for linux systems, that is how do sizes of library on linux (*.a/*.la file) relate with size of linux executable (*.out) ?

-AD

推荐答案

.lib 文件中有额外的簿记信息,这些信息对于最终的可执行文件是不需要的.此信息可帮助链接器找到实际链接的代码.此外,调试信息可能存储在 .lib 文件中,但不在 .exe 文件中(我不记得在 lib 文件中为 objs 存储调试信息的位置,它可能在别的地方).

There is additional bookkeeping information in the .lib file that is not needed for the final executable. This information helps the linker find the code to actually link. Also, debug information may be stored in the .lib file but not in the .exe file (I don't recall where debug info is stored for objs in a lib file, it might be somewhere else).

这篇关于库和可执行文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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