Reduce compiled application size on lazarus

Last updated on December 1, 2012 @ No comments yet

I’m new to lazarus, it’s a great replacement for delphi IDE. I was amazed in the first place how lazarus as a freeware work great on linux. Only, i have one tiny problem with lazarus which is as default lazarus included the debug info and libraries on every project which caused the compiled file size become so large.  Even just fot a simple “hello world” GUI application, the compiled application can growth into more than 21 Mb. Pretty waste of space for only a hello world application.

But it was only for active development process. On lazarus application production, debug info should be removed in order to reduce the file size as small as possible. I can’t imagine how big the application size will be if more complicated project is compiled on lazarus with debug info on it.

Free Pascal uses GDB as debugger and LD as linker. These work with a system of in-binary debuginfo, be it stabs or dwarf. People often see e.g. Lazarus binaries that are 40MB. The correct size should be about 6MB, the rest is debuginfo (and maybe 6 MB from not smartlinking properly) – (

Since i’m a newbie on lazarus and i don’t really understand how to debug the codes, i prefer to remove the debugging info from compiled application.

lazarus compiled

At first i was reducing compiled file with strip and upx compressor command line which reduced the 20mb application down to 3mb. But then i saw lazarus faq which informing the better setting to reduce file size.

lazarus simple hello world

According to lazarus faq page there are 4 steps to reduce compiled binaries, that is:

  • Open Project Options, on the Linking menu, Enable “Smart Linkable” link style,
  • Enable “Strip symbols from executable”,

lazarus options

  • Disable “Generate Debugging Info for GDB” (on the bottom left option windows, check “use this compilers option as default for new project”, if you want to make it as default), and save option by clicking OK.
  • Compress binaries with “upx”.

lazarus win 32

This option work better for Win32 Aplication even without upx compression.

M Riza

Article by M Riza

Is a blogger since 2007, founder and editor of Oa Ultimate. Working as a network administrator, computer technician, database and web maintainer | Twitter | G+

Leave a Reply


Loading Google+ Comments ...
Loading Facebook Comments ...