Link to home
Start Free TrialLog in
Avatar of samuel_chinnu123
samuel_chinnu123

asked on

how do i reduce the delphi exe file size

Hi everyone
              how do i reduce the delphi exe file size, if i create a application in delphi the minimum size is 360 kb , but in other languages i can create it in two digit kbs , so how do i over come this , and what increases the file size of a delphi application ,
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Imbeginner
Imbeginner

the easy way...
-Use delphi 2
-Use ResHacker to pull out all unneeded resources from exe
-Pack with UPX using this command line
UPX --best MyApp.exe

the hard way...
Use KOl library or use API

The really hard way..
Give up on delphi and use something like the free LCCWin32 C compiler... you will be rewarded with extremely small size exes... some of mine are 5kb in size.

You might also use the free BCX basic to C translator... it turns basic source into C source that LCCWin32 can compile... BCX is nearly as easy to use as Delphi.. it is free and has a nice rad environment called ezide.
There is also a user group for BCX full of friendly guys that will help you along.

:-)
As to what increases the size of a delphi exe

Borland decided that being able to quickly develop programs was more important than making them really small... and they are right!

But if you compare Delphi apps to VB apps you will see that it is VB that is bloated. The runtime file for VB is just HUGE... compared to that delphi makes small exe's.

With 512mb memory chips at 49.00 and 120gb HDs at 120.00 exe size is NOT important unless you get beyond 1mb. Anything less than 1mb can be downloaded quickly even on a 28.800 dial-up :-)
In delphi select Project|Options and select the Linker tab, set Map File to Off, set Linker Output to Generate DCUs and untick all the EXE and DLL options.

All EXEs created in delphi have a .reloc section which for EXEs is never needed as they never get relocated in memory like dlls do. so to get rid of that you can use StripReloc from

http://www.jrsoftware.org/files/striprlc.zip

the source code is included with this too :)

once you strip the .reloc section from your EXE you could then use UPX as mentioned above to further reduce the size

The only other thing i can think of would be to copy the forms unit (rename it to MyForms) and take out all the code you can that still allows your code to compile then in the uses section, replace Forms with MyForms(i had done this before and it worked wonders for me, but i have gone through a few Hard Drive formats since then forgetting to back it up and i can't be bothered to go back through it again)

Hope something is useful to you

Hill Groover
samuel_chinnu123:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.