Board index » delphi » Reducing EXE filesize

Reducing EXE filesize

When compiling a project Delphi links many vcl libraries unnecessary for the
program?Does anyone know how to avoid this unnecessary linking to reduce the
exe filesize?
But I still want a stand alone executable.

Thank you in advance,
Bill

 

Re:Reducing EXE filesize


Quote
Bill Libb wrote in message <1056632281.683627@athprx02>...
>When compiling a project Delphi links many vcl libraries unnecessary for
the
>program?Does anyone know how to avoid this unnecessary linking to reduce
the
>exe filesize?

Remove units from your uses clauses if they're not actually used.

Delphi features "smart linking": only routines (procedures, functions,
methods) that are or could be called are linked into the executable.
But that's for code: all data is always included, and some library
units have quite substantial amounts of global variables. Also, virtual
methods that are in fact never called tend to be included because they
_might_ be called. It would take extensive program analysis to exclude
all code that cannot be called.

Quote
>But I still want a stand alone executable.

That's not a problem.

At the end of the day, executable size itself is not a problem. The
best solution is not to worry about it. Make some effort to keep your
uses clauses tight, and stop right there.

Groetjes,
Maarten Wiltink

Re:Reducing EXE filesize


Quote
Bill Libb wrote:
> When compiling a project Delphi links many vcl libraries unnecessary
> for the program?

Like what, for instance?

--
Rob

Re:Reducing EXE filesize


http://upx.sourceforge.net/

"Bill Libb" <libb_the_gr...@yahoo.com> schreef in bericht
news:1056632281.683627@athprx02...

Quote
> When compiling a project Delphi links many vcl libraries unnecessary for
the
> program?Does anyone know how to avoid this unnecessary linking to reduce
the
> exe filesize?
> But I still want a stand alone executable.

> Thank you in advance,
> Bill

Re:Reducing EXE filesize


Rob Kennedy <rkenn...@example.com> wrote in news:vfm8f07ffsi950
@corp.supernews.com:

Quote
> Bill Libb wrote:
>> When compiling a project Delphi links many vcl libraries unnecessary
>> for the program?

> Like what, for instance?

Grab Icarus from http://www.peganza.com/products.htm

This will go through you project and tell you what units should be moved
(to the implementation section) and what units should be removed.

Cheers,
Nick

Re:Reducing EXE filesize


Quote
Nicholas Ring <Nicholas.R...@NOSPAM.smf.com.au> wrote:
> > Bill Libb wrote:
> >> When compiling a project Delphi links many vcl libraries unnecessary
> >> for the program?

> > Like what, for instance?

> Grab Icarus from http://www.peganza.com/products.htm

> This will go through you project and tell you what units should be moved
> (to the implementation section) and what units should be removed.

Thanks for the link. I may need that too. But I figured that the
Delphi compiler was smart enough not to link unused library code
into the executable. Or am I giving it too much credit now?

Re:Reducing EXE filesize


On 27 Jun 2003 02:20:35 -0700, b...@mindless.com (Bram Bos) wrote:

Quote
>Nicholas Ring <Nicholas.R...@NOSPAM.smf.com.au> wrote:

>> > Bill Libb wrote:
>> >> When compiling a project Delphi links many vcl libraries unnecessary
>> >> for the program?

>> > Like what, for instance?

>> Grab Icarus from http://www.peganza.com/products.htm

>> This will go through you project and tell you what units should be moved
>> (to the implementation section) and what units should be removed.

>Thanks for the link. I may need that too. But I figured that the
>Delphi compiler was smart enough not to link unused library code
>into the executable. Or am I giving it too much credit now?

It is pretty smart, however t{*word*220} the Uses list is always a good
idea - just as a matter of principle
- it is a form of self documentation, also a trap for scope problems

Re:Reducing EXE filesize


Quote
"Bram Bos" <b...@mindless.com> wrote in message

news:e386cf42.0306270120.44a044a1@posting.google.com...

Quote
> Thanks for the link. I may need that too. But I figured that the
> Delphi compiler was smart enough not to link unused library code
> into the executable. Or am I giving it too much credit now?

It is fairly smart. However it doesn't remove virtual method code. IMO
spending much time on this is an utter waste. In a Windows app far more
space is consumed by resources and other data than by code.

Re:Reducing EXE filesize


Quote
Bruce Roberts wrote:
> "Bram Bos" <b...@mindless.com> wrote in message
> news:e386cf42.0306270120.44a044a1@posting.google.com...

>>Thanks for the link. I may need that too. But I figured that the
>>Delphi compiler was smart enough not to link unused library code
>>into the executable. Or am I giving it too much credit now?

> It is fairly smart. However it doesn't remove virtual method code.

That shouldn't matter in this case. Removing an unused unit won't take
care of unused virtual methods. The virtual methods will only be
included if you use the class those methods belong to (or one of its
descendents). If you use the class, then the unit obviously isn't
unused, and you'd get a compiler error if you tried to remove it.

To remove a unit and not get compiler errors, the unit's effect on the
program must be limited to its initialization and finalization sections,
the units it uses, and any resources linked via that unit. Removing any
of those side effects can cause problems when running the program.

--
Rob

Other Threads