Delphi:带有内置软件包的.exe:600kb,.exe +外部 BPL:6MB。这是为什么?
如果我用内置包在delphi中编译.exe文件,它会生成大约600kb的EXE文件。但是,如果我使用运行时包对其进行编译,则大小总和(.exe + 所有必需的 .BPL)约为 6-8 MB(取决于编译器的版本)。为什么差异如此显着?
if I compile .exe file in delphi with built-in packages, it generates about 600kb EXE file. However if I compile it with runtime packages, the sum of sizes (.exe + all required .BPLs) is about 6-8 MB (depending on version of compiler). Why is the difference so significant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为如果您运行正常编译,链接器可以在 DCU 上进行“智能链接”并删除您的程序永远不需要的代码。但这些包是预先构建的,并且包含所有代码,因此您无法将它们智能链接到更小的大小。
Because if you run a normal compile, the linker can do "smart linking" on the DCUs and remove code that your program never needs. But the packages are prebuilt and have all the code included, so you can't smartlink them down to a smaller size.
我认为您假设在生成带有内置 BPL 的程序时链接了整个 BPL 文件。事实并非如此。在编译的最后阶段,Delphi 编译器将所有内容链接在一起。在那里,它省略了 BPL 中但不被程序直接或间接调用的模块。
因此,最终的占用空间要小得多,只有实际需要的模块位于最终的 exe 中。
I think you assume the whole of the BPL files are linked in when you generate a program with built-in BPL's. That is not the case. In the final stage of compilation, the Delphi compiler goes into linking everything together. There it omits the modules, that are in the BPL's but not called directly or indirectly by your program.
So, you end up with a much smaller footprint, only the modules actually needed are in the final exe.