PDA

View Full Version : How to reduce Lazarus 0.9.30 project exe file size?



paul_nicholls
16-06-2011, 04:12 AM
Hi all,
I have a Lazarus project that I converted over from Delphi automatically (pas2c64 (http://www.pascalgamedevelopment.com/showthread.php?6660-Pas2C64)) and it is produce a huge .exe file!!

It only uses 1 form (with 2 SynEdit components, 2 groupbox, 1 splitter, and two buttons) and some custom units, but the .exe file is 17.9MB in size....WTF!?!

I am sure that I have turned on smart-linking and optimization to make it smaller, not faster, but to no avail :(

Any ideas?

I am wondering if I might have to create a new project manually and copy over the used units, etc. from my current one to see if it shrinks down?

cheers,
Paul

dazappa
16-06-2011, 04:25 AM
Hi all,
I have a Lazarus project that I converted over from Delphi automatically (pas2c64 (http://www.pascalgamedevelopment.com/showthread.php?6660-Pas2C64)) and it is produce a huge .exe file!!

It only uses 1 form (with 2 SynEdit components, 2 groupbox, 1 splitter, and two buttons) and some custom units, but the .exe file is 17.9MB in size....WTF!?!

I am sure that I have turned on smart-linking and optimization to make it smaller, not faster, but to no avail :(

Any ideas?

I am wondering if I might have to create a new project manually and copy over the used units, etc. from my current one to see if it shrinks down?

cheers,
Paul

If you are ready to create a release build of your application:
Go to Project -> Project Options
Under Compiler Options / Linking -> check -Xs
Under Compiler Options / Code Generation you may want to check Level 3 optimizations

The executables are big due to the debugging information, so I say only check -Xs when you are ready to release or you'll have a hard time debugging. Even after this step, your executables will be significantly larger with Lazarus than Delphi and many other languages, but that is the nature of the beast. 1-4MB sure beats 17MB though. (On Windows you could also look into using UPX, but many virus scanners seem to detect UPX'd executables as potential viruses)

(Also under linking if you have other debugging related options set, such as -g you might want to remove them as well. I haven't done a lot of testing with it though [as to whether or not strip will remove them as well])

In related news, the stripping is its own executable which you can use without Lazarus, should the need arise

mobilus
16-06-2011, 04:42 AM
...and Under Compiler Options / Linking -> uncheck -gl

paul_nicholls
16-06-2011, 04:52 AM
Thanks guys :)

I will see how I go...I'm not ready to do a release build yet, but I will note the info ;)

cheers,
Paul