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?
Delphi: .exe with built-in packages: 600kb, .exe + external BPLs: 6MB. Why is that?
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.
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.
Not just entire modules. The smartlinker can cut out individual functions and procedures from within a unit if it determines that they're never used. –
Bacolod
© 2022 - 2024 — McMap. All rights reserved.