问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/17119132/how-can-i-reduce-the-size-of-a-compiled-delphi-code