您的位置:首页 > 编程语言 > Delphi

Delphi XE8 程序瘦身.编译后EXE最低90KB.

2016-01-21 10:03 567 查看
目前网络上 XE8程序瘦身基本为XE5以前的方法,虽然该方法也必须援用之前方法.但需要说明一下,现在release比debug瘦身效果相差无几.我的XE8单独窗体EXE文件为11056KB.瘦身后exe文件最低可以达到 90KB.

下面是方法介绍.

第一步:关闭debug infomation.

打开工程后,依次点击project--option--delphi compiler--linking 将右边Debug information改为False.

编译后Debug和Release版都为2142KB.

此处参考http://www.delphifans.com/InfoView/Article_6493.html



第二步: 关闭RTTi.

点击Project--view source.在第二行添加编译开关代码

{ Reduce EXE size by disabling as much of RTTI as possible (delphi 2009/2010) }

{$IF CompilerVersion >= 21.0}

{$WEAKLINKRTTI ON}

{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

{$IFEND}

编译后Debug和Release版都为1728KB.



第三步:设置运行时包.

打开工程后,依次点击project--option--Packages--Runtime Packages 勾选Link with runtime package.

编译后Debug的exe文件为90Kb,Release为1728KB



对于第三步,如不是太计较exe大小,则不是太建议.请看帮助资料.

Runtime packages are deployed with your applications. They provide functionality when a user runs the application.

To run an application that uses packages, a computer must have both the application's executable file and all the packages (.bpl files) that the application uses. The .bpl files must be on the system path for an application to use them. When you deploy an
application, you must make sure that users have correct versions of any required .bpls.

这意味着当选择使用该选项的debug版时,你必须把正确的bpl文件一起放在应用程序目录或系统目录.我一个单按钮窗体程序必须拷贝2个bpl文件.

正确的bpl在\Embarcadero\Studio\16.0对应的文件夹里面找,比如我的虚拟xp,则为\Embarcadero\Studio\16.0\Bin目录

而且如果修改了某个控件源码,意味这必须重编译该控件.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: