Too big file size lazarus / 13-General ---------------------------------------------------------------------- Anonymous · 2003-12-17 08:48 The size of the compiled file (only with one empty form) is about 3 Mb (both under Linux and Windows). How  can I reduce it??? UPX compressor (under Win) reduce size to 1 Mb, but anyway ... its too big. IMHO, the size of one empty form must be ~ 200-300 Kb. Any ideas??? Tham ---------------------------------------------------------------------- vrs · 2003-12-17 13:52 You won't get to the 200-300 Kb limit, but you can do some other things to reduce executable 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. Compiling with fpc 1.0.10 gives me an executable for windows of 843 KB.  You might be able to compress this with UPX more, but I don't know it works (if it only strips debugging info, you won't win very much). The size of the minimal executable will grow as the implementation of the win32 interface gets more complete. For a much smaller executable a redesign of the comminucations of the LCL with the underlying widget set (GTK or win32 ATM) is needed, to take much more advantage of smart linking. As things are now, almost all code of the LCL is included in the binary, even if it is not used in the application. Vincent. ---------------------------------------------------------------------- IgD · 2004-02-24 10:45 Vincent, what do you think about adding this EXE size information to the FAQ?  Also what do you think about setting the options to make the smallest EXE by default? ---------------------------------------------------------------------- Anonymous · 2004-04-08 14:52 On Linux you may strip the binary file and you'll get a ~ 4:1 compresion ---------------------------------------------------------------------- mikiwoz · 2004-11-09 00:23 OK then, when the eager community of Lazarus users can expect to be totally shocked by an executable with size of, say, 512KB? THAT would be something really BIG! As a Delphi exec of a fairly complicated and long-sourced program, as we all know, I suppose, is uuhm... something about 300-400KB?.. Anyway, whenever these Beautyful  New Times will come - I must say, Lazarus is a great tool!.. But then again - it would be nice to know... Regards Mike ---------------------------------------------------------------------- Lightning · 2004-11-09 09:42 UPX best compression achieved like this : upx --best myexecutable This compresses the Lazarus executable from 21MB to 5.5MB, now that's compression. ---------------------------------------------------------------------- Lightning · 2004-12-09 19:29 3 things to get smaller apps: 1-Smartlink(doesn't work well with the debugger activated) 2-Strip(the latest strip isn't the best ) 3-Compress using UPX After these operations i'm sure your apps will be much smaller, comparable to Delphi 6-7 standalone executables. ---------------------------------------------------------------------- Anonymous · 2004-12-15 18:36 apart from using upx that seems like a cheat smartlinking increases the exe size instead of reducing it stripping does not strip anything or maybe there is nothing to strip but anyway does not reduce the exe size every change in the compiler/linker option does not help reducing filesize and the smaller helloworld app i have obtained on win32 was 5.69mb if someone has better advice or knows a straight way to get a light exe please reply on this forum thanks in advance and sorry for my keyboard lacks the shift and comma keys ---------------------------------------------------------------------- Almindor · 2004-12-15 18:44 Actualy UPX is the ONLY hack. Smartlinking is a nice way of compiling things by taking only those methods which they use from the library. You probably done something wrong. an empty form here smartlinked and stripped is: 1.4 Mb(linux) My game which doesn't use LCL(or lazarus, only FPC) is 180kb. Main problem is smartlinking works only with procedures/functions. It doesn't work with classes. NOTE: fpc produces static binaries. a static hello world C program is 1 megabyte. ---------------------------------------------------------------------- Anonymous · 2004-12-15 20:44 something really goes wrong opened a new project with an empty form in win32 with default installation options switched on smartunits and smartlinking and stripping switched off line number generator build project and get a brand new exe of 8.01mb then... switched off smartunits and smartlinking and stripping switched on line number generator build project and now the exe is 5.29mb any other combination of the above options increase the filesize what am i doing wrong [question mark] please help me, i feel depressed [gee my comma key works again] ---------------------------------------------------------------------- Lightning · 2004-12-17 12:22 You might want to use another strip version, it seems the one you're using is bad, i had a buggy one myself in the latest installer, but i think it's fixed now. My apps are about the same as delphi apps in size, using smartlinking, stripping and upx, of course delphi apps are smaller after upx but comparable (no big difference). You are doing something wrong but i don't see what ---------------------------------------------------------------------- smace · 2005-01-14 22:49 I dont even like to look my Lazarus app size. When my free space is over I know who is guilt for this ;-) ---------------------------------------------------------------------- Lightning · 2005-01-16 09:54 This is important for non-opensource apps wich have to be downloaded by people with slow connections. ---------------------------------------------------------------------- Anonymous · 2005-01-17 10:46 Probably, it could help. Rebuild your LCL distribution with all stripping and code optimization options on. After that compile your program. I was shocked but it realy reduced executable size. Don't realy know, but on my opinion, LCL that ships with Lazarus is compiled with no optimization, stripping  and a lot of debug info in. This is, IMHO, the reason of monsterous size of your apps. (Probably this is my mistake, but recompiling LCL realy resulted in my exe size reduce). 2All, Have a nice programming. Lazarus, freepascal teem--thanks for your work. ---------------------------------------------------------------------- Vincent Snijders · 2005-01-17 16:33 The LCL is built with debug info on purpose otherwise you won't be able to step through the LCL code, only your onw code. Since lazarus is a development tool, being able to debug is more important then quickly making small executables. ---------------------------------------------------------------------- Anonymous · 2005-01-20 15:51 if all works ok and i would like to have release of my application, why shouldn't it be possible to compile my program with LCL compiled without debug info? Probably, it should be option, integrated in IDE. Bcz now, we have to "dance" with direcrories, with "symbols on" and "symbols stripped". ---------------------------------------------------------------------- Cactus · 2005-04-25 17:11 Did any one know MASM32? it made a base GUI application just 7 KB. see the example1 of masm32. why Lazarus make a 1MB executable? ---------------------------------------------------------------------- Cactus · 2005-04-25 17:53 Quote from: "Anonymous"Probably, it could help. Rebuild your LCL distribution with all stripping and code optimization options on. After that compile your program. I was shocked but it realy reduced executable size. Don't realy know, but on my opinion, LCL that ships with Lazarus is compiled with no optimization, stripping  and a lot of debug info in. This is, IMHO, the reason of monsterous size of your apps. (Probably this is my mistake, but recompiling LCL realy resulted in my exe size reduce). 2All, Have a nice programming. Lazarus, freepascal teem--thanks for your work. That's great. I just one by one seek the source of LCL. they is in \lazarus\lcl\interfaces\win32 how I rebuild them? ---------------------------------------------------------------------- Anonymous · 2005-05-10 17:03 As I remember in  Delphi there are  RTL and other important units in two separated forms : stripped and optimized and also with full debug info. Could it be possible with Lazarus also ? I don't get it - I have empty window application in Lazarus about 8 MB in size ! ---------------------------------------------------------------------- Marc · 2005-05-11 10:05 To make the lazarus distribution about twice the size ? Naaaah. use strip. ---------------------------------------------------------------------- Anonymous · 2005-05-17 22:16 There are some problems with the win32 LD.exe not stripping even when you tell it to, so also try manually, from the \pp\..\bin\ directory, at the command prompt using strip c:\mypath\project1.exe Then you should have about a 1MB project. I guess it is still related to the LCL being included in the program versus the VCL being different.. I have to read up on that though, because I thought smartlinking was for smartlinking... i.e. not including everything in the LCL. More studying to do.. ---------------------------------------------------------------------- Anonymous · 2005-05-17 22:18 but just using strip alone may not reduce it to the maxiumum, recompiling the LCL without debug still should help trim off about 500kb (correct me if I am wrong..) ---------------------------------------------------------------------- Anonymous · 2005-05-19 08:46 It's no happy programming where need strip exe file and pack UPX. It's very bad style for development programm. I needs outputs exe have size ~100-400 kb. If this not so then it's bad IDE RAD. ---------------------------------------------------------------------- Anonymous · 2006-03-03 10:24 Why not have recompiling lazarus libaries for small size as an option during setup? Why not have debug and release versions of the EXE (debug with full debug info) release - stripped off, small in size? ---------------------------------------------------------------------- lepidosteus · 2006-03-03 12:30 Quote from: "Anonymous"It's no happy programming where need strip exe file and pack UPX. It's very bad style for development programm. I needs outputs exe have size ~100-400 kb. If this not so then it's bad IDE RAD. There is no relation between the IDE RAD capability and the exe size. But nice try. Oh, and lazarus alow to set 'after compilation' and 'before ocmpilation' program to execute, simply put a batch or sh file there wich will do the job for you ... It took me like 10 seconds to think about that instead of whining about the ide itself. ---------------------------------------------------------------------- felipemdc · 2006-03-03 16:54 This thread is very old, no need to revive it. There is more scientific information about smartlinking and filesizes on the Wiki, here: http://wiki.lazarus.freepascal.org/index.php/File_size_and_smartlinkin g ---------------------------------------------------------------------- Anonymous · 2006-03-10 11:13 Maybe you need the ask the creators of KOL (Key Objects Library) how do they do it =) My base KOL projects create about 18kt exe files using UPX. I think it is a marvelous piece of work. For those who don't know, KOL replaces the VCL units with KOL units, creating ~10x smaller code while no runtime-libraries used. ---------------------------------------------------------------------- Anonymous · 2006-04-17 06:05 well I had a 15.6 MB executable I enabled smartlinking and stripped it. And no debug... and it stayed the same size... but then I switched off generate line numbers and the executable dopped amazingly down too 1.54 MB... Thats pretty cool. I think the reason is for small GUI affects I just used a lot of procedures like mouse enters..... but thats neat... I'm really liking this. The really neat thing is after that I upx packed it with --force and --best and it knocked it down too 451 KB... I mean that is really cool. This program has a lot of functionality to it already. And with very unorganized code. This proves for me in my oppinion then delphi. If i was to totally recreate this program in delphi. It would surpass 20 mb THUMBS UP MAN!! ---------------------------------------------------------------------- Anonymous · 2006-04-17 23:08 Quote from: "Cactus"Did any one know MASM32? it made a base GUI application just 7 KB. see the example1 of masm32. why Lazarus make a 1MB executable? That is Assembler code, Makes small and fast executables... But extremely low-level and not really needed. Why code in ASM just for the filesize unless it's some sort of competition its not worth it at all. Stick with pascal or c++. ASM is not worth the time.