[Lazarus] Strange dependency of units

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Mar 31 14:25:13 CEST 2012

On Sat, 31 Mar 2012 13:51:28 +0200
J├╝rgen Hestermann <juergen.hestermann at gmx.de> wrote:

> I have my own general purpose unit with functions and procedures I often 
> use. There are also some routines that operate on TStringGrid types so I 
> had to add GRIDS to the uses clause in the interface part of this unit. 
> If I now write a very simple "Hello World" program that uses just one 
> simple function from my unit I get errors
> Error: Undefined symbol: WSRegisterCustomImageList
> Error: Undefined symbol: WSRegisterMenuItem
> etc.
> at the end of my program. After a long searching I found out that I had 
> to add INTERFACES to the uses clause of my program. My questions:
> How should anybody know that this is required in this situation?
> Why is the INTERFACES unit not required in the unit itself?

Grids is is part of the platform independent LCLBase. 
The unit 'interfaces' (i.e. package LCL) provides the
It is similar to a class like TStrings with abstract methods and the
a full class like TStringList.
The compiler can tell that "TStrings.Create" is a bad idea, but it can
not tell what full class to use instead.
It's the same with Grids. The compiler can tell that the implementation
is missing, but you have to choose the implementation.

The IDE has some automatic checks for LCL applications. Maybe some can
be extended.

Hint: When you use Cody to add the grids unit to the uses section, it
will automatically add the LCL as dependency.


More information about the Lazarus mailing list