Re:Free Pascal
by fmntf on Sunday December 13, 2020 @01:14PM
(#25408662)
Sometimes I need to create a small GUI application for my Windows colleagues. Using Qt or .NET I get huge binaries/dependencies. What is the final binary size (all deps included) with your solution for a "hello world" GUI exe?
[ Parent
| on HN ]
This was written a few years ago with FPC v2.2 (latest is FPC v3.2), but generally matches my experience:
https://wiki.freepascal.org/Size_Matters#Analysis_of_various...
tl;dr is that if you create a RELEASE build, should be about 2 - 5mb for a GUI app, depending on the platform. And if you run `upx` against the resulting binary, it will be even smaller.
Win 7 x64:
------------
- 12.3 mb == Default build
- 3.2 mb == Default build without debug info
- 2.1 mb == Optimized compiler
- 2.1 mb == Optimized compiler without debug info
Ubuntu x64:
------------
- 13.4 mb == Default build
- 7.5 mb == Default build without debug info
- 4.4 mb == Optimized compiler
- 2.7 mb == Optimized compiler without debug info
Optimized compiler means: 1. Project|Compiler Options|Code|Smart Linkable (-CX) -> Checked
2. Project|Compiler Options|Linking|Debugging| Uncheck all except `Strip Symbols From Executable (-Xs) -> Checked`Strip Symbols From Executable (-Xs) -> Checked
3. Project|Compiler Options|Linking|Link Style|Link Smart (-XX) -> Checked
4. (Optional) Project|Compiler Options|Code|Optimizations|smaller rather than faster -> Checked (Warning: this might decrease performance)I get 2.1 MB win32 and 6.9 MB Ubuntu x64 with fpc 3.2
Which is rather bad. I used to use Delphi 4 and it would create 350 KB programs by default.
Which was also bad, so I sometimes used that Delphi without the GUI designer and without the VCL, using the win32 API directly, to create 50 KB programs. That is a reasonable software size. Software keeps getting worse every year
A rather small GUI windows program with few dependencies is 1-2 MB; if you pass it through UPx (https://upx.github.io/) it will be less than 1 MB. Take a look at this program https://github.com/spapas/pdfsigner/releases/tag/v1.0 build with lazarus if you want to see how it looks like.