Recent

Author Topic: Decrease the size of the executable of Lazarus  (Read 11264 times)

elidorio

  • Sr. Member
  • ****
  • Posts: 295
Decrease the size of the executable of Lazarus
« on: July 26, 2015, 06:53:58 pm »

Hello Guys,

What do I need to configure on lazarus, to decrease the size of the executable?


--
Edson
Lazarus 1.4.4 | FPC 2.6.4 | Windows / Linux Debian

lainz

  • Hero Member
  • *****
  • Posts: 3884
Re: Decrease the size of the executable of Lazarus
« Reply #1 on: July 26, 2015, 07:12:23 pm »
First know that the smallest size I can get under a Windows GUI Application x86 is: 1,82 MB. With the default form and units.

Go to Project > Project Options > At the top of the form there is a button right to "Build modes" with three dots "...". Click on it and choose "Create Debug and Release modes". Then when you compile switch to "Release".

Try removing the icon file and you will reduce the size too.

If you do a command line application you get: 30,5 KB. If you don't need GUI this is a lot smaller.

You can also compress the executable with http://upx.sourceforge.net/. But it generally is catched by AntiVirus software and people here and there has reasons on not doing this... something about memory usage.

I don't know if using fpGUI or some other you get less MB's.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9776
  • FPC developer.
Re: Decrease the size of the executable of Lazarus
« Reply #2 on: July 26, 2015, 07:18:29 pm »
Manually doing win32 API is also fairly small. The RAD combined with the portability and details like translation support make the size a bit larger. (but 1.82 MB is not that different from a current Delphi)

Bart

  • Hero Member
  • *****
  • Posts: 4606
    • Bart en Mariska's Webstek
Re: Decrease the size of the executable of Lazarus
« Reply #3 on: July 26, 2015, 07:24:21 pm »
Read the FAQ?

Bart

elidorio

  • Sr. Member
  • ****
  • Posts: 295
Re: Decrease the size of the executable of Lazarus
« Reply #4 on: July 26, 2015, 07:38:38 pm »
Had a huge difference with mode release.
From: 70,664 fell to 7,109.

Excellent result.
Lazarus 1.4.4 | FPC 2.6.4 | Windows / Linux Debian

Leledumbo

  • Hero Member
  • *****
  • Posts: 8402
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Decrease the size of the executable of Lazarus
« Reply #5 on: July 27, 2015, 01:34:52 am »
First know that the smallest size I can get under a Windows GUI Application x86 is: 1,82 MB. With the default form and units.
It's smaller here, only 1562112 bytes (1.5 MB) with application icon removed. The secret is to compile everything (including LCL) optimized without any debug info ;)

lainz

  • Hero Member
  • *****
  • Posts: 3884
Re: Decrease the size of the executable of Lazarus
« Reply #6 on: July 27, 2015, 02:31:56 am »
Had a huge difference with mode release.
From: 70,664 fell to 7,109.

Excellent result.


Good job.

First know that the smallest size I can get under a Windows GUI Application x86 is: 1,82 MB. With the default form and units.
It's smaller here, only 1562112 bytes (1.5 MB) with application icon removed. The secret is to compile everything (including LCL) optimized without any debug info ;)

I forget to remove application Icon. I remembered that removing the icon works after writing the 1,82 MB size.

You're right, optimizing everything you'll get smallest and faster code, I forget that too since I never do it, just tested that thing only one time about some years ago and never again. Without optimizing and removing the icon I get 1,69 MB.

Compiled with rebuilding the IDE with 'Optimized IDE' I get 1,60 MB.

Optimizing LCL, FCL, LCLBase, LazUtils does not make any difference with the 'Optimized IDE' for me. I get 1,60 MB. The same.

So you Win ;) by some kb. Maybe I'm missing something, I have FPC 2.6.4 and Lazarus 1.4.2.

Removing the manifest (under Windows) I save 1kb ;)

Applications that I compile for x64 are always bigger.

FPC units can be recompiled and also optimized right? But not from the Lazarus IDE..
« Last Edit: July 27, 2015, 02:38:35 am by lainz#007 »

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Decrease the size of the executable of Lazarus
« Reply #7 on: August 03, 2015, 01:21:16 pm »
I don't know if using fpGUI or some other you get less MB's.
Yes, a single Form application can get down to about 750KB with fpGUI - plus it has a much smaller 3rd party dependency that LCL based applications. eg: no need for GTK or Qt libraries and their dependencies.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

BeniBela

  • Hero Member
  • *****
  • Posts: 824
    • homepage
Re: Decrease the size of the executable of Lazarus
« Reply #8 on: August 03, 2015, 01:37:13 pm »
Manually doing win32 API is also fairly small.

True

I was always upset when the old Delphi versions made 350 KB applications. Far too big.

Not using VCL brought it down to 40 KB.

Anything larger is a crazy waste of space.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9776
  • FPC developer.
Re: Decrease the size of the executable of Lazarus
« Reply #9 on: August 03, 2015, 02:22:42 pm »

Not using VCL brought it down to 40 KB.

Anything larger is a crazy waste of space.

Unfortunately win32 api programming  is a crazy waste of time :-) Time vs space, the eternal question.

Thaddy

  • Hero Member
  • *****
  • Posts: 11134
Re: Decrease the size of the executable of Lazarus
« Reply #10 on: August 03, 2015, 02:35:05 pm »
That's why we developed and we maintain KOL. Close to the metal of the winapi, but rather comfortable.
KOL windows GUI applications start from 50k and isn't much different from VCL programming if you use KOL&MCH 2.88. see the wiki under KOL and KOLCE.
You have morons, I am one, and you have morons squared.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1087
Re: Decrease the size of the executable of Lazarus
« Reply #11 on: August 03, 2015, 03:10:18 pm »
hello,
Thaddy have you success to use KOL CE with Lazarus 1.4 ? Not sure that KOL CE works with the new versions of Lazarus without patches.

Friendly J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Thaddy

  • Hero Member
  • *****
  • Posts: 11134
Re: Decrease the size of the executable of Lazarus
« Reply #12 on: August 03, 2015, 03:14:53 pm »
We have made kol 3.22/23 compatible with fpc 3.1.1. and tested that extensively.
Currently I am reworking mck from KOLMCK 2.88 to support that.
Since I rarely use Lazarus this is a bit of a struggle, but it will be done.
Meantime: writing KOL applications from scratch isn't that difficult  ;)
I even have a lazarus template for that.
You have morons, I am one, and you have morons squared.

engkin

  • Hero Member
  • *****
  • Posts: 3058
Re: Decrease the size of the executable of Lazarus
« Reply #13 on: August 03, 2015, 03:38:05 pm »
Anyone looking to reduce the size of the executable file should take a look at this post by skalogryz.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9776
  • FPC developer.
Re: Decrease the size of the executable of Lazarus
« Reply #14 on: August 03, 2015, 03:41:36 pm »
I would place my bets on Nikolay :-)

 

TinyPortal © 2005-2018