0

I just wrote a really short and simple code in Delphi with no even arrays neither data structures and when I compile it I get a 11 MB exe file, it was compiled for 32 bits architecture under RAD Studio X3 IDE for 64 bits.

I think this isn't optimal, even a jar would weigh less!

Are there any settings I can do so I get a smaller compiled? Maybe any units I can dismiss in the code?

diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
  • 2
    And [How to achieve smaller size of the executable](http://stackoverflow.com/q/2150025/62576). Please at least do a scan through the `Related` list before posting your question to see if it's been asked and answered here before. You should also at least make an effort to search the site; searching for `[delphi] executable size` would have turned up both of the other links even if they weren't in the `Related` list. – Ken White Jun 15 '13 at 02:39
  • Don't use VCL. Don't use FireMonkey. Don't use stock RTL. Use KOL/MCK for GUI and their modular RTL drop-in replacement. I did GUI-less DLLs as small as 2KB :-) – Arioch 'The Jun 15 '13 at 10:45
  • @Arioch'The How can I do that setting? I'm a total newbie for Delphi and gotta write a code for the weekend – diegoaguilar Jun 15 '13 at 14:04
  • @Arioch'The, KOL/MCK has been abandoned. It have *curio and relic* status nowadays. – OnTheFly Jun 16 '13 at 08:09
  • 1
    You do realize that a JAR file is hardly going to run on some user's computer without a java runtime which is LARGER than 11 MB to download these days. :-) Turn on the Use-Runtime-BPLs and you'll get your java style SMALL binary, that requires a huge amount of runtime ... And now you are becoming enlightened I hope? – Warren P Jun 16 '13 at 19:41

1 Answers1

4

You need to disable debug information in your executable, which will strip out things like debug symbols from the executable. Check the linker options in RAD Studio on how to do this.

Edit (for the sake of validity/completion): You also have to switch to release instead of debug configuration - the linked question has an answer that's described in this page.

Options that will increase the size of your executable are:

  • Full debug information: as mentioned, this will include debug symbols, which will make the size of your executable much bigger
  • Link with Dynamic RTL: Controls if Delphi Run Time Library (RTL) is built into the executable, or as an external DLL. Embedding it in the executable with increase its size significantly
  • Link with the Delphi Runtime Library

You can also pack your executable with an executable packer, like UPX.

Community
  • 1
  • 1
Filippos Karapetis
  • 4,367
  • 21
  • 39
  • 3
    One small thing to point out - if you do decide to use a packer like UPX, it helps to remember that this technique can often trick antivirus software into thinking that your executable is malware! This is referred to as a 'false positive', and will give you a hard time when you release your software to the public. – AudioGL Jun 15 '13 at 02:59
  • This is a very good and wise advice, thanks! – diegoaguilar Jun 15 '13 at 03:29