Default executable file size settings lazarus / 13-General ---------------------------------------------------------------------- IgD · 2005-02-15 02:06 Today I created a new application without any added components and compiled it.  The size of the output executable was over 5 megs!  We've discussed this before.  There are several options that can be tweaked to greatly reduce the file size: In the compiler options dialog - on the Code tab choose Unit Style: Smart - on the Linking tab: Unceck all the checkbox except the last one in the Debugging groupbox; choose Link Smart in the Linking Libraries groupbox. Imagine for a second that you are a Delphi user who has never used Lazarus before.  You want to evaluate Lazarus to see if its right for you.  You install it, create a simple application, drop a button to the form that says "Hello world" when clicked.  Then you compile the application.  Imagine the reaction when you see the size of your executable is 5 megs! Take a look at Delphi, the default settings are such as to optimize the size of the output executable.  Would you please set Lazarus the same way?  Most of the end user types are going to want these options set to make the smallest executable. ---------------------------------------------------------------------- Vincent Snijders · 2005-02-15 03:23 No, unless you will explain, why lazarus ignores breakpoints etc ;-) Again: IMHO an IDE should support debugging rather than small executable size by default. ---------------------------------------------------------------------- IgD · 2005-02-15 03:29 Vincent, I can't think of any compiler that is set this way.  Take a look at Delphi or any of the Microsoft products.  They are all set to have a minimal EXE size by default.  The concern is, potential Lazarus users see the executable size and are scared away.  Do you really need a big EXE for breakpoints?  Delphi seems to support breakpoints without that. ---------------------------------------------------------------------- Vincent Snijders · 2005-02-15 03:34 I don't how Delphi does this. The microsoft compilers I know, have seperate files for debug information and don't store that information in the executable as fpc does. ---------------------------------------------------------------------- Marc · 2005-02-15 11:06 Quote from: "IgD"Vincent, I can't think of any compiler that is set this way.  Take a look at Delphi or any of the Microsoft products.  They are all set to have a minimal EXE size by default.  The concern is, potential Lazarus users see the executable size and are scared away.  Do you really need a big EXE for breakpoints?  Delphi seems to support breakpoints without that. Nope, delphi debuginfo is turned on by default.  The point that delphi exes (and debug infos) are smaller is that delphi has a better smartlinking on classes since it has its own internal linker. With the current (external) linker, every virtual method cannot be smartlinked and is thus compiled in. If you want small exes, you may want another comiler, if you want a fasst comiler, use FPC. Who cares about size nowadays ? ---------------------------------------------------------------------- Anonymous · 2005-02-16 08:21 I think 70% of people still care about exe size and speed both. True they compromise on size when they add huge addons such as dev- express (and they know what they are doing). An exe size of 5MB for a barebone executable seems too large by any standard !!! Can someone tell me how can we change the linker that ships with Lazarus/Fre Pascal and which ones are smart enough Warm regards ---------------------------------------------------------------------- Lightning · 2005-02-16 08:56 FPC uses the GNU linker wich is not optimised, it consumes much memory and the executables are big. You can get smaller executables by smartlinking and removing debug information but the GNU debugger won't work after that, you may even compress the executables with UPX. After all these operations the executables will be just a little bigger than Delphi ones. Making CrossPlatform linkers/debuggers is hard and for the moment the GNU ones are usable. ---------------------------------------------------------------------- IgD · 2005-02-16 18:45 How about something clever like compiling 2 exe's when run inside the IDE:  The first could be a temporary file with all the debug information.  The second could be the normal exe used for production. On a related note, the Lazarus EXE is 20 megs.  Is the Lazarus EXE compiled with all the debug information or could it be compiled with the smart options? ---------------------------------------------------------------------- Almindor · 2005-02-16 21:50 Lazarus is entirely compiled with debug info. Making big and possibly even unoptimized. Don't forget Lazarus is BETA. You can't expect a beta to focus on anything else than stabilizations and finalization. NOTE: DON'T compile lazarus with smartlinking. You'll get stuck for hours with the linker doing it. NOTE#2: it's possible that there will be a FPC linker made sometime in the future. When, by whom(well that's partially known) and how good depends on many things including user contributions. But it's still somewhere in the clouds I guess. ---------------------------------------------------------------------- Vincent Snijders · 2005-02-17 08:03 IgD, while developing, debug information should be enabled by default. If you want to go to production, you can use the publish project dialog. I am sure it contains one or two bugs, but you can even create a -bat file that strips and upx-es the resulting executable. The makefile for Lazarus automatically adds the debug information and it can't be turned off. You can strip the executable afterwards. That is why the executable in the lazarus win32 installer is 6-7 MB only. ---------------------------------------------------------------------- Anonymous · 2005-02-23 16:06 Lazarus executables will be huge until LCL design will be changed. Current LCL design is not optimized for smartlinking. Many unused code from other controls is included in executable even for empty project with one form. An approach of registering widget classes is not good. This approach puts the code of all widgets into executable even if it is not needed. ---------------------------------------------------------------------- marmin · 2005-02-25 15:42 Quote from: "Anonymous"I think 70% of people still care about exe size and speed both.  ... An exe size of 5MB for a barebone executable seems too large by any standard !!! Yes, imo a size of 5 !! Mb for a form with no labels etc. is quite large indeed. I am a Delphi programmer and just testing Lazarus, but I was really amazed. I wonder what the filesize is for really large programs. When I zipped the file, the size was reduced to 1.2 Mb ---------------------------------------------------------------------- Lightning · 2005-02-25 16:41 If you strip symbols you get about 1.5 MB and if you UPX it you get about 400KB about the same size of a Delphi7 executable and if you UPX a Delphi executable you get about 200-300KB executable. Don't forget to strip !!! FPC smartlinking can't be applied to classes yet, inheriting also contributes to bigger executables. ---------------------------------------------------------------------- marmin · 2005-02-25 16:54 Where can I d-load the UPX, and, why is it not included in Lazarus. And, I checked the 'strip symbols', and I also checked 'smart linkable' unit style. I also disabled 'smart linking', because when I enabled that that the file size increased to a staggering -7.8 Mb - for an empty little form, ha, ha. That is almost 25 Pengo arcade roms. In short, it all helped shit to reduce any size. ---------------------------------------------------------------------- Almindor · 2005-03-03 12:28 It all helped shit because the old(0.9.4) laz. version included LD(that's a LINKER for windows users) which didn't abide to -Xs(strip) New version has this fixed (new linker) AFAIK. If you still get 3mb+ apps, fire up your ugly windows console(that's the black box you get in xp when you run "cmd btw.) and go to your project directory(remember where you put it?, good) and type strip "myproject.exe" Now IF and I REPEAT IF you have FPC in path(which I doubt) you should get your executable stripped. IF you don't, you need to put it in path. IF you have a big all in one lazarus, your fpc binaries directory is somewhere in it. Otherwise C:\pp I guess... ---------------------------------------------------------------------- marmin · 2005-03-03 20:28 There's a bug: the strip in Lazarus don't function. If i set the 'strip symbols' in Lazarus then nothing happens. If I strip 'manually' the file is decreased. A lot. ---------------------------------------------------------------------- retnyg · 2005-03-17 17:07 Code: [Select] program project2; {$apptype console} begin  writeln('hello world'); end. this has a stripped filesize of 95 KB, if compiled directly with FPC it has 23 KB, why like this ? ---------------------------------------------------------------------- Almindor · 2005-03-18 10:07 smartlinking? ---------------------------------------------------------------------- Lightning · 2005-03-18 11:26 I get a 5KB smaller exe with smartlinking, there must be something else... ---------------------------------------------------------------------- Almindor · 2005-03-19 22:08 non-working stripping? ---------------------------------------------------------------------- Nisbo · 2005-03-20 06:01 here an other exe packer: http://www.ensacom.de/index.php?s=dl&voll=1&id=25&page=&kat=Tools ---------------------------------------------------------------------- retnyg · 2005-03-21 00:38 the goal shouldnt be the use of exe-packers but generating small code by itself. still i wonder why a Lazarus console binary without any units has 4 times the size of a "pure" FPC binary ---------------------------------------------------------------------- yuriy_sydorov · 2005-03-21 11:34 I get the same sizes of empty project from Lazarus and from "pure" FPC. RTL units must be compiled with smartlinking enabled (-CX switch). ---------------------------------------------------------------------- caitken · 2005-04-14 11:12 I think the two versions (debug and published) of the same executable has merit - From a user's point of few - I either want to debug or I want to run the finished app.  The two files approach would simplify things I think.  It would be a nice touch if lazarus took care of running the strip utility etc. The current publish option under the project menu does some weird things at present (V0.9.6). ---------------------------------------------------------------------- andi456 · 2005-04-21 10:05 QuoteLazarus executables will be huge until LCL design will be changed. Current LCL design is not optimized for smartlinking. Many unused code from other controls is included in executable even for empty project with one form. An approach of registering widget classes is not good. This approach puts the code of all widgets into executable even if it is not needed. I first thought that the above could point into the right direction, but the last few posts in this thread made my confusion complete. So what does lazarus do, when it compiles? Where could I learn something about this issue? Greets Andreas ---------------------------------------------------------------------- Anonymous · 2005-05-10 17:32 How backtrace behaves when EXE is stripped ? Is there any magical way to get unreadable backtrace from stripped EXE and get backatrace with full lines and units info like in backtrace from debug version of EXE ? Maybe some clever utility for this ? I consider this idea : building two exe's : with and without debug info but exactly the same code , get unreadable backtrace , and use EXE with debug info to get readable backtrace or maybe even directly jump to line/unit where bug occured ? Isn't that a good idea ? ---------------------------------------------------------------------- Anonymous · 2005-05-17 22:58 One rather stupid hack you could do is make your 4MB lazarus program (or however big it is) into a DLL. Then create a simple FPC "launcher" program. Then your users will think your EXE is only 15KB when in fact it's calling on a 4MB lazarus DLL. (or. .SO in linux) That's a stupid hack though... it's just useful if you want to re-use your DLL with several programs, or if you want to fool your users into thinking their program is only 15KB. Lars ---------------------------------------------------------------------- Anonymous · 2005-07-16 09:06 In fpc config you can change Debug or Release mode, how Lazarus works with this options, or it just ignore it? ---- SNK ---------------------------------------------------------------------- FrankIT · 2006-04-27 14:45 Help me! I've done all the optimize that you've suggested, but i didn't manage to get a smaller exe!  :cry: Where is the problem? ---------------------------------------------------------------------- Marmin_ · 2006-04-29 04:43 It's Fixed ! Thank you, now exes are < 1 mb ! You have to enable smart linking , 2 TIMES (there are 2 tabs where you have to enable smart l. and you also must disable all debugger checkboxes.) Cheers ! ---------------------------------------------------------------------- FrankIT · 2006-04-30 22:15 But when I uncheck the third debbugger checkbox i get a 10 megs exe! Why?