How can I reduce the size of a compiled Delphi code? [duplicate]

南楼画角 提交于 2019-12-11 15:11:50

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17119132/how-can-i-reduce-the-size-of-a-compiled-delphi-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!