Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: .exe with built-in packages: 600kb, .exe + external BPLs: 6MB. Why is that?

Tags:

exe

delphi

bpl

if I compile .exe file in delphi with built-in packages, it generates about 600kb EXE file. However if I compile it with runtime packages, the sum of sizes (.exe + all required .BPLs) is about 6-8 MB (depending on version of compiler). Why is the difference so significant?

like image 775
migajek Avatar asked Aug 21 '09 14:08

migajek


2 Answers

Because if you run a normal compile, the linker can do "smart linking" on the DCUs and remove code that your program never needs. But the packages are prebuilt and have all the code included, so you can't smartlink them down to a smaller size.

like image 85
Mason Wheeler Avatar answered Sep 28 '22 13:09

Mason Wheeler


I think you assume the whole of the BPL files are linked in when you generate a program with built-in BPL's. That is not the case. In the final stage of compilation, the Delphi compiler goes into linking everything together. There it omits the modules, that are in the BPL's but not called directly or indirectly by your program.

So, you end up with a much smaller footprint, only the modules actually needed are in the final exe.

like image 45
Rocky Luck Avatar answered Sep 28 '22 11:09

Rocky Luck