[Lazarus] Strange dependency of units

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Apr 1 15:15:21 CEST 2012


Mattias Gaertner schrieb:
 >> That's exactly what I did. I used Larazus to create a console
 >> application. I then added my general purpose unit to the uses clause.
 >> Then compile failed with an error message that had nothing to do 
with my
 >> program or unit.
 >
 > A console application is for simple stdin/stdout programs that runs in
 > the DOS box, the OS X terminal, the Linux shell, etc.

Exactly. That's what I wanted to create. I only included my general 
purpose unit which I also use for LCL programs. Some functions exist in 
this unit that operate on TStringGrid type (but I did not use them in my 
console program) so I had to add GRIDS to the uses clause of this unit. 
The astonishing thing now is, that my (console) program only compiles 
when I add the interfaces unit to the program although I never actively 
used it.


 >> *) Write a unit
 >> *) Create a program (via Lararus) that uses the unit (which I use in
 >> nearly all programs)
 >>
 >> What is wrong with this?
 >
 > Nothing. The unit just can not work on its own. You just have to
 > add an implementation.

??
On its own? I used it in my (console) program.
Add an implementation? My program is a simple text mode console program. 
Why should I have 'added' something to it?

 
 > As I wrote two times: It does not need interfaces.
 > Here is an example that compiles without interfaces:
 >
 > program project1;
 > {$mode objfpc}{$H+}
 > uses
 >   Classes, Grids, NoGUIWSFactory;
 > begin
 > writeln('Works');
 > end.

When I create a new console application, delete everything in it and add 
your program from above I get:
"Can't find unit Grids used by project1."
Why can't it find this unit? Lazarus was installed with it. So it should 
know where it has put it.


 > It is not enough to use unit "interfaces", a normal LCL application
 > also requires an Application.Initialize call.

I did *not* want to create an LCL application! It was a simple console 
program.






More information about the Lazarus mailing list