如何减小编译Delphi代码的大小? [英] How can I reduce the size of a compiled Delphi code?

查看:304
本文介绍了如何减小编译Delphi代码的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 Delphi 中写了一个非常简短的代码,甚至没有数组也没有数据结构,当我编译它时,我得到一个 11 MB的exe文件在64位的RAD Studio X3 IDE下编译为32位架构。



我认为这不是最佳的,甚至是 jar 会减重!



有没有任何设置我可以做,所以我得到一个较小的编译?

解决方案

您需要禁用可执行文件中的调试信息,例如从可执行文件调试符号。请查看RAD Studio中的链接器选项,了解如何进行此操作。 / p>

编辑(为了有效/完成):您还必须切换到发布,而不是调试配置 - 链接的问题有答案在此页中进行了说明。



将增加可执行文件大小的选项有:




  • 完整调试信息:将会包含调试符号,这将使可执行文件的大小更大。

  • 与动态RTL链接:控制 Delphi运行时库(RTL)内置在可执行文件中,或作为外部DLL。将其大小显着地增加到可执行文件中

  • 与Delphi运行库关联



您也可以使用可执行文件打包程序打包可执行文件,例如 UPX


I just wrote a really short and simple code in Delphi with no even arrays neither data structures and when I compile it I get a 11 MB exe file, it was compiled for 32 bits architecture under RAD Studio X3 IDE for 64 bits.

I think this isn't optimal, even a jar would weigh less!

Are there any settings I can do so I get a smaller compiled? Maybe any units I can dismiss in the code?

解决方案

You need to disable debug information in your executable, which will strip out things like debug symbols from the executable. Check the linker options in RAD Studio on how to do this.

Edit (for the sake of validity/completion): You also have to switch to release instead of debug configuration - the linked question has an answer that's described in this page.

Options that will increase the size of your executable are:

  • Full debug information: as mentioned, this will include debug symbols, which will make the size of your executable much bigger
  • Link with Dynamic RTL: Controls if Delphi Run Time Library (RTL) is built into the executable, or as an external DLL. Embedding it in the executable with increase its size significantly
  • Link with the Delphi Runtime Library

You can also pack your executable with an executable packer, like UPX.

这篇关于如何减小编译Delphi代码的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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