Recent

Author Topic: size of EXE file  (Read 25137 times)

Lacak2

  • Guest
size of EXE file
« on: February 11, 2009, 09:46:56 am »
Hi *,
I am sure, that this is common question.  :(
I have also found articles speaking about it
(http://wiki.lazarus.freepascal.org/Lazarus_Faq#Why_are_the_generated_binaries_so_big.3F), but I do not fully understand it.

In my very simple example I have one form and one label and button on it.
When I compile project, I get 12MB size executable.
I have tried some options in Compiler options/Linking, but without effect ...

When I use strip.exe on 12MB executable I get 1.5MB executable ... which is fine.

Why Lazarus does not use "strip.exe" by default in Building process ?
Or is there any switch, which I have missed ?

TIA
-Laco.

fonsagrada

  • Newbie
  • Posts: 3
Re: size of EXE file
« Reply #1 on: February 11, 2009, 10:17:15 am »
You can change the settings of the compiler and the result is the same as if using "Strip.exe".

Loesje

  • Full Member
  • ***
  • Posts: 157
    • Lazarus Support website
Re: size of EXE file
« Reply #2 on: February 11, 2009, 10:18:32 am »
You can not debug a stripped executable. In most cases the executable size doesn't matter at all. (See this link which is in the faq you mentioned)

In some cases it could be an issue when you want to distribute your application. then you can call strip. But that's something you don't do very often, so it can be done manually.

Which you also can do is enable all smart-linking options and the strip-symbols options for the compiler. You can find all information on this on the wiki/documentation/faq's etc

LacaK

  • Hero Member
  • *****
  • Posts: 577
Re: size of EXE file
« Reply #3 on: February 11, 2009, 10:55:28 am »
You can change the settings of the compiler and the result is the same as if using "Strip.exe".

Which settings ?
When I check "Strip symbols from executable -Xs" on Compiler options/Linking tab ... it has no effect
When I check "Link smart -XX" on same tab ... it has no effect

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
Re: size of EXE file
« Reply #4 on: February 11, 2009, 11:09:32 am »
Project->Compiler options->Linking
In "Debugging" uncheck all items but "Strip symbols from executable"

LacaK

  • Hero Member
  • *****
  • Posts: 577
Re: size of EXE file
« Reply #5 on: February 11, 2009, 12:01:15 pm »
Yes, thanks it works now!

By default is checked "Display line numbers in Run-time ... (-gl)".

So when I checked "Strip symbols from executable -Xs" nothing happens ... but I expected, that stripping happens.

So if I understand it correctly, -Xs has no effect if any of other options in Debudding panel is checked ... If it is true ... It would be good if these checkboxes will be mutualy exclusive.
(so when I check -Xs then all others will be unchecked or -Xs will take precedence over other switches ?)
May be I am wrong ?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: size of EXE file
« Reply #6 on: February 12, 2009, 04:03:28 am »
Quote
-Xs has no effect if any of other options in Debudding panel is checked
Try mixing -Xs and -gl on the command line and see the result, I've never done that myself.
Quote
It would be good if these checkboxes will be mutualy exclusive.
I agree with this, so the programmers don't mix them and get unexpected result.

Handoko

  • Hero Member
  • *****
  • Posts: 3185
  • My goal: build my own game engine using Lazarus
Re: size of EXE file
« Reply #7 on: February 12, 2009, 06:50:35 am »
There are many ways to make it smaller.

Here is my easy step to make it fat loss:
- Copy the strip.exe from C:\lazarus\fpc\2.2.2\bin\i386-win32
- Paste it to your project folder
- Using Command Prompt, type: strip YourProject.exe
- And be happy with the result.

Before you strip it off, make sure you are ready to realease it at final build. Because it will strip off the debug information, that means you can not do any debugging later.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: size of EXE file
« Reply #8 on: February 12, 2009, 09:11:47 am »
Quote
- Using Command Prompt, type: strip YourProject.exe
For a release, I prefer strip -s (or --strip-all) instead of just strip. Be careful, don't do it to a library or you won't be able to link to it anymore.
« Last Edit: February 12, 2009, 09:13:43 am by Leledumbo »

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: size of EXE file
« Reply #9 on: February 12, 2009, 09:14:58 am »
Quote
-Xs has no effect if any of other options in Debudding panel is checked
Try mixing -Xs and -gl on the command line and see the result, I've never done that myself.
Quote
It would be good if these checkboxes will be mutualy exclusive.
I agree with this, so the programmers don't mix them and get unexpected result.
It makes the chance for bugs in the compiler options handling larger. And if the logic behind the options changes somehow (it doesn't happen often, but it does sometimes), you might not be able to set the options you wish.

Lacak2

  • Guest
Re: size of EXE file
« Reply #10 on: February 13, 2009, 07:50:57 am »
I can share with you my personal experience ...
Before years, when I have used Lazarus first time (I cam to Lazaris from Delphi), I made "small test application", when I have compiled it I got 10MB executable file ... because this was not acceptable for me (comparing to Delphi < 1MB) I have returned back to Delphi.
(My conclusion was, that so large size is because of multi-platform character of Lazarus, FPC)
After years I returned back to Lazarus, because of need produce application for WinCE ... I make "small test application" ;-) and I get 12MB executable ... so I start searching on web ...
What I want to say is, that I am as end-user, developer expecting :
FAST & SMALL executable ... and I expect, that default setting in IDE will be set so.
Let see at Compiler options/Linking/Debugging :
If I uncheck default checked "Display Line Numbers in Run-time Error-backtraces" (so no checkbox is checked in panel Debugging)... size of EXE is about 1.5MB ...  :o
Can not it be a default state after install?
If not, then some notice may be post during linking process ?
If not, then may it be documented somewhere, that it is possible and how to set up IDE to produce "stripped" exe (without manual using strip.exe)?
Please look at this "case" from POV Delphi user, where compiled exe is small.
-Laco.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: size of EXE file
« Reply #11 on: February 13, 2009, 10:43:13 am »
Can not it be a default state after install?

I wouldn't do that, because then the same people would complain that the debugger doesn't work.
But it would indeed be nice to have a Run and a Debug mode.
Run would switch off gdb and debug info, while Debug would do what it's doing now in default mode.

Lacak2

  • Guest
Re: size of EXE file
« Reply #12 on: February 13, 2009, 02:37:31 pm »
But it would indeed be nice to have a Run and a Debug mode.
Run would switch off gdb and debug info, while Debug would do what it's doing now in default mode.
Or two menu items in Run menu :
"Build"
"Build with debug"

Bart

  • Hero Member
  • *****
  • Posts: 3538
    • Bart en Mariska's Webstek
Re: size of EXE file
« Reply #13 on: February 13, 2009, 03:25:31 pm »
I use the IDE to develop my programs, that means I always want to be able to debug. So I want this by default.
Stable, published versions I strip manually.
Yes, a 350 K executable (D3) is nice, but hardly anyone I know complains about a 2 M exectable (GUI).

Bart

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: size of EXE file
« Reply #14 on: February 13, 2009, 03:37:05 pm »

It's not about exe size in my case, but I don't need the debugger for every part of development.
Sometimes it crashes for no obvious reason and I use writeln for sending debugging info to the console a lot.
The latter is not working when running under gdb. Resp. gdb is not working when I use xterm.

So I think having both possibilities at hand without having to switch on and off via settings would be nice.
It's not extremely important but it would be nice.