[Lazarus] Large program size - 1.8 MB for empty GUI project

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Apr 8 09:36:49 CEST 2009


On Wed, 8 Apr 2009 08:40:38 +0200
Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:

>[...]
> > To avoid this and to make the LCL usabole as "library", most unit
> > circles were removed. One way to ensure that is by putting all uses
> > in the interface section.
> 
> OK I'm confused. How does solving circular reference get resolved by
> putting everything in the Interface section? 

In order to break the circles, you must first find them. Move all uses
to the interface section and FPC will find them for you.


> Doing that is what causes circular reference problems?? 

?


> Maybe I understand circular reference
> problems differently to you... this is what I mean:
> 
> ====================
> { this defines TClass1 }
> unit Unit1;
> 
> uses
>   unit2;
> 
> type
>    TClass1 = class(TObject)
>    private
>       FRef: TClass2;
>     end;
> 
> ....
> ====================
> 
> { this defines TClass2 }
> unit Unit2;
> 
> uses
>   unit1;
> 
> type
>    TClass2 = class(TObject)
>    private
>       FRef: TClass1;
>     end;
> 
> ....
> =============================
> 
> Both classes require each other and can't be compiled. This is what I
> understand as circular unit references.  To solve this you can lump
> both class definitions in a single unit and add a 'forward
> declaration' at the top.

Yes.

 
>[...]
> OK, I worded that wrong. For smartlinking there shouldn't be any
> difference if the unit is in the Interface or Implementation section.

Yes.


> What is important is if the unit is used or not.

Only if the unit has an initialization section.

For example simply adding uses Math; without using any part will not
increase the exe (using smart linking).


> I think the reason I
> can get such small executables, is because every gui component lives
> in it's own unit. 

This has nothing to do with smart linking. But it helps to keep the
keep the exe small without smart linking.
For the LCL this would not help much - see other mails.


> fpGUI doesn't have a StdCtrls or ComCtrls unit which
> lumps a whole bunch of classes together. And when I create
> applications I only add the units I really need. This is obviously
> key.



Mattias



More information about the Lazarus mailing list