Ver Mensaje Individual
  #14  
Antiguo 05-04-2012
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Sobre el tamaño de los ejecutables:

Cita:
Empezado por lazarus
Why are the generated binaries so big?

The binaries are big because they include a lot of debug information necessary for using gdb (GNU Debugger).
The compiler has an option to remove the debug information from the executable (-Xs), but due to a bug in the compiler (version 2.0.2 and earlier), this doesn't work correctly. It has been fixed in version 2.0.4 and later of the compiler.
You can use a program called "strip" to remove the debug symbols from the executable file. It is located under lazarus dir lazarus\fpc\2.4.2\bin\i386-win32\.
Just type "strip --strip-all <your executable file with path>" on the command line.
If you want to make your program even smaller, you should try UPX too. UPX is a very good exe compressor. It includes no memory overhead due to in-place decompression. It also has a very fast decompression (~10 MB/sec on an Pentium 133).
To use upx just type "upx <your executable file with path>" on the command line.
after using both strip and upx a simple GUI Lazarus program gets:
  • ~ 700kb on Linux
  • ~ 420kb on Windows
A more detailed answer with the drawbacks of using UPX is given on Size Matters.
It's also important to note that the hello world lazarus software already includes a huge amount of features. It includes:
  • XML handling library
  • Image handling library for png, xpm, bmp and ico files
  • Almost all widgets from the Lazarus Component Library
  • All of the Free Pascal Runtime Library
So it's very big, but it already includes almost everything a real world non-trivial app will need.
Lazarus executable size starts big, but grows very slowly, because of the Free Pascal compiler and the way lazarus forms operate. A c++ project (just an example, but applies to other languages / tools too) starts very small on the hello world, but quickly grows exponentially when you need features to write a non-trivial application.

Quick guide to Lazarus/FPC application size reduction (tested with Lazarus 0.9.26)
  • 1. Project|Compiler Options|Code|Smart Linkable (-CX) -> Checked
  • 2. Project|Compiler Options|Linking|Debugging| Uncheck all except
Strip Symbols From Executable (-Xs) -> Checked
  • 3. Project|Compiler Options|Linking|Link Style|Link Smart (-XX) -> Checked
The most important items seem to be 2. For a simple application the executable size should now be 1-3 MB instead of 15-20 MB. At this point you can also try: Project|Compiler Options|Code|Optimizations|smaller rather than faster -> Checked (Warning: this might decrease performance)
  • 4. (Optional) Run UPX <your_executable> to compress your binary by an additional factor of 2-3 (Warning: as indicated above, there are drawbacks to using UPX).
Chart of default sizes for an empty Application with various settings and operating systems
Well I ran tests I did on Lazarus 0.9.29 with FPC 2.4 (FPC 2.2.4 with Windows). Optimized compiler mean using the advices above but without using UPX. Default Lazarus means as installed from package/setup. LCL without debug informations mean after rebuilding Lazarus IDE and LCL without debug informations (-g-).

Default Lazarus LCL without debug informations Ubuntu 64 bits / Lazarus 64 bits
Default application 13,4 Mb 7,5 Mb / 8 Optimized compiler 4,4 Mb 2,70 Mb (0.29svn FPC2.4 2,5)
Ubuntu 32 bits / Lazarus 32 bits
Default application 19,6 Mb 5,7 Mb Optimized compiler 2,9 Mb 1,6 Mb
Windows XP 32 bits / Lazarus 32 bits
Default application 11,8 Mb 2,14 Mb Optimized compiler 1,62 Mb 1,50 Mb
Windows Seven 64 bits / Lazarus 64 bits
Default application 12,3 Mb 3,20 Mb Optimized compiler 2,14 Mb 2,16 Mb
Responder Con Cita