[Lazarus] Strange dependency of units

classic Classic list List threaded Threaded
74 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Strange dependency of units

Jürgen Hestermann
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?


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
On Sat, 31 Mar 2012 13:51:28 +0200
Jürgen Hestermann <[hidden email]> 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
implementation.
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.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
 >> How should anybody know that this is required in this situation?
 >> Why is the INTERFACES unit not required in the unit itself?
 >
 > Grids is part of the platform independent LCLBase.
 > The unit 'interfaces' (i.e. package LCL) provides the
 > implementation.

How should I know this?

And why do I *not* need the INTERFACES unit in my general purpose unit?
There I only 'use' GRIDS.


 > It is similar to a class like TStrings with abstract methods and
 > 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.

Well, I don't know anything about packages. I come from Turbo/Virtual
Pascal. I always struggle with this very strange concept of packages. It
seems that it generates more problems than it saves. I only want to use
libraries (units). It was just a great step forward with Turbo Pascal to
introduce the concept of units. No need to think about dependencies
anymore. If you use a unit that again uses other units the compiler/IDE
took care about these things and the only need was to configure where to
search for them (which was already done for libraries that came with the
IDE). In case it missed the source of a unit it clearly told me *which*
unit it could not compile. But now I have to fight with these internals
myself. I have to learn all about used packages (which units do they
include? which dependencies exist? etc.) even when I'm writing a simple
'Hello World' program that uses a simple unit. Strange.



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

What is Cody? As said: I added the 'uses grids' clause to my unit only.
I don't need it in my simple console program. I also never added the
grids unit to my other programs. The compiler should know what it has to
compile (and link) because it was declared in the unit. If I create a
graphic program with Larazus' 'new project' function the INTERFACES unit
is added automatically to the program (but no GRIDS!). But if I create a
new console program and then use my unit (because I need some non-grid
functions) I get errors but don't know what they are all about.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Reinier Olislagers
On 31-3-2012 15:08, Jürgen Hestermann wrote:
>> Hint: When you use Cody to add the grids unit to the uses section, it
>> will automatically add the LCL as dependency.
>
> What is Cody?
http://wiki.lazarus.freepascal.org/index.php?title=Special%3ASearch&search=cody&fulltext=Search

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
Reinier Olislagers schrieb:
> On 31-3-2012 15:08, Jürgen Hestermann wrote:
>  
>>> Hint: When you use Cody to add the grids unit to the uses section, it
>>> will automatically add the LCL as dependency.
>>>      
>> What is Cody?
>>    
> http://wiki.lazarus.freepascal.org/index.php?title=Special%3ASearch&search=cody&fulltext=Search
>  
This reminds me on this: http://www.ztw3.com/forum/forum_entry.php?id=114358
You answer sounds like the Linux part ;-)
Is Lazarus on the same way?

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Reinier Olislagers
On 31-3-2012 15:22, Jürgen Hestermann wrote:

> Reinier Olislagers schrieb:
>> On 31-3-2012 15:08, Jürgen Hestermann wrote:
>>  
>>>> Hint: When you use Cody to add the grids unit to the uses section, it
>>>> will automatically add the LCL as dependency.
>>>>      
>>> What is Cody?    
>> http://wiki.lazarus.freepascal.org/index.php?title=Special%3ASearch&search=cody&fulltext=Search
> This reminds me on this:
> http://www.ztw3.com/forum/forum_entry.php?id=114358
> You answer sounds like the Linux part ;-)
> Is Lazarus on the same way?

No idea.
Just wanted to encourage you that there often is documentation about
concepts... even though it may not always be complete or correct.

Regards,
Reinier

BTW: Haven't learned Java, so I suspect that's actually good ;)

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

David W Noon
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 15:22:05 +0200, Jürgen Hestermann wrote about Re:
[Lazarus] Strange dependency of units:

> http://www.ztw3.com/forum/forum_entry.php?id=114358 You answer sounds
> like the Linux part ;-) Is Lazarus on the same way?

Hey!  I run Gentoo Linux, so there is no step 2 on my machines.  I am
permanently in step 1.  ... :-))
--
Regards,

Dave  [RLU #314465]
=======================================================================
[hidden email] (David W Noon)
=======================================================================

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 15:22:05 +0200
Jürgen Hestermann <[hidden email]> wrote:

> Reinier Olislagers schrieb:
> > On 31-3-2012 15:08, Jürgen Hestermann wrote:
> >  
> >>> Hint: When you use Cody to add the grids unit to the uses section, it
> >>> will automatically add the LCL as dependency.
> >>>      
> >> What is Cody?
> >>    
> > http://wiki.lazarus.freepascal.org/index.php?title=Special%3ASearch&search=cody&fulltext=Search
> >  
> This reminds me on this: http://www.ztw3.com/forum/forum_entry.php?id=114358
> You answer sounds like the Linux part ;-)
> Is Lazarus on the same way?

In the past the programs that used only parts of the LCL compiled, but
would then later fail at runtime at some strange place. Now you already
see at compile time that something is missing. That's definitely better.

And the IDE has already some checks for common mistakes.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
In reply to this post by Reinier Olislagers
Reinier Olislagers schrieb:
 > Just wanted to encourage you that there often is documentation about
 > concepts... even though it may not always be complete or correct.

Of course, if I *wanted* to get information about "Cody" I know that I
could use Google.
The question was: Do I *need* to know about it to program with Lazarus?


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
In reply to this post by Mattias Gaertner
Mattias Gaertner schrieb:
 > In the past the programs that used only parts of the LCL compiled, but
 > would then later fail at runtime at some strange place. Now you already
 > see at compile time that something is missing. That's definitely better.

Of course, you are right: It could be even worse.


 > And the IDE has already some checks for common mistakes.

Mistake? Using a self-written unit is a mistake? Not knowing that GRIDS
requires INTERFACES is a mistake?
Shouldn't GRIDS have a uses clause for INTERFACES?
If yes, why is it not included?
If no, why is this so?

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Reinier Olislagers
In reply to this post by Jürgen Hestermann
On 31-3-2012 16:36, Jürgen Hestermann wrote:
> Reinier Olislagers schrieb:
>> Just wanted to encourage you that there often is documentation about
>> concepts... even though it may not always be complete or correct.
>
> Of course, if I *wanted* to get information about "Cody" I know that I
> could use Google.
> The question was: Do I *need* to know about it to program with Lazarus?
vs
On 31-3-2012 15:08, Jürgen Hestermann wrote:
"What is Cody?"

????

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
Reinier Olislagers schrieb:
 >> Of course, if I *wanted* to get information about "Cody" I know that I
 >> could use Google.
 >> The question was: Do I *need* to know about it to program with Lazarus?
 > vs
 > On 31-3-2012 15:08, Jürgen Hestermann wrote:
 > "What is Cody?"
 > ????

Well, my question was a reaction to Mattias' "hint":

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

I found this a bit astonishing because why should I use anything else
than my keyboard to add a unit to my program? And because I never heard
about "Cody" before I wrote "What is Cody?". It was just yet another
answer in the sense that it does not answer your question but instead
hints you to yet another topic so that you get into the
Linux-problem-solve mechnism to waste your live on another topic that
leads you to another topic that leads you to another topic..  over and
over again. You only never get back to solve your original problem, you
may even forget about it. The reason for the success of Turbo Pascal was
just that you did *not* have to have all the knowledge about what
happens in the background. I painfully miss this idea in Lazarus.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 16:42:53 +0200
Jürgen Hestermann <[hidden email]> wrote:

> Mattias Gaertner schrieb:
>[...]
>  > And the IDE has already some checks for common mistakes.
>
> Mistake? Using a self-written unit is a mistake? Not knowing that GRIDS
> requires INTERFACES is a mistake?

?
You asked on which way Lazarus is and I gave examples where things are
getting easier. Of course there is always room for more helpers.

You made the mistake to use grids without an implementation (e.g. LCL
interfaces).

> Shouldn't GRIDS have a uses clause for INTERFACES?
> If yes, why is it not included?
> If no, why is this so?

I already tried to explain that. I'm not sure what you did not
understand about the concept of "abstract method". Maybe this helps:
The LCL "interfaces" is just one possible implementation. Theoretically
you can implement another one. At the moment the LCL unit "interfaces"
is the only supported one.
Theoretically it might be possible to use interfaces in grids, but
that would make many other things more complicated.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 17:04:16 +0200
Jürgen Hestermann <[hidden email]> wrote:

> Reinier Olislagers schrieb:
>  >> Of course, if I *wanted* to get information about "Cody" I know that I
>  >> could use Google.
>  >> The question was: Do I *need* to know about it to program with Lazarus?
>  > vs
>  > On 31-3-2012 15:08, Jürgen Hestermann wrote:
>  > "What is Cody?"
>  > ????
>
> Well, my question was a reaction to Mattias' "hint":
>
> "When you use Cody to add the grids unit to the uses section, it will
> automatically add the LCL as dependency."
>
> I found this a bit astonishing because why should I use anything else
> than my keyboard to add a unit to my program?

You can use the Cody dictionary with your keyboard only.


> And because I never heard
> about "Cody" before I wrote "What is Cody?". It was just yet another
> answer in the sense that it does not answer your question but instead
> hints you to yet another topic so that you get into the
> Linux-problem-solve mechnism to waste your live on another topic that
> leads you to another topic that leads you to another topic..  over and
> over again. You only never get back to solve your original problem, you
> may even forget about it. The reason for the success of Turbo Pascal was
> just that you did *not* have to have all the knowledge about what
> happens in the background. I painfully miss this idea in Lazarus.

I'm sorry for trying to help you and I'm glad that Lazarus users are
so spoiled.
The hint was a about a tool that reduces the burden of knowing to
which package a unit belongs, search paths and dependencies.
If you have trouble with "hints" then just ignore them.


Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 13:51:28 +0200
Jürgen Hestermann <[hidden email]> 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

I added a FAQ, improved the jump in the messages window and added a
comment in the sources.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
In reply to this post by Mattias Gaertner
Mattias Gaertner schrieb:
 > The hint was about a tool that reduces the burden of knowing to
 > which package a unit belongs, search paths and dependencies.

Why is this at all necessary? I don't get it of what use such a
complicated and error prone construct like packages should serve for if
it is not rock solid. Is this an improvement over simple to use units?
In units, all dependencies are automatically(!) resolved by the
software. Why is this impossible for packages? I was not even aware that
I used a package. I just used a unit (grids).


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Jürgen Hestermann
In reply to this post by Mattias Gaertner
Mattias Gaertner schrieb:
 > You made the mistake to use grids without an implementation (e.g. LCL
interfaces).

Implementation? What's this again? It's no longer enough to use a unit?
Sorry, but it seems that there is a very steep learning curve even for
former (Turbo..) Pascal programmers.
I have to learn a lot just to be able to program with Lazarus. It seems
to be for long term nerds only.
It has become nearly as complicated as C and relatives.


 > I'm not sure what you did not understand about the concept of
"abstract method".

Everything. If it leads to such results this concept seems to be not
very good.


 > The LCL "interfaces" is just one possible implementation. Theoretically
 > you can implement another one. At the moment the LCL unit "interfaces"
 > is the only supported one.

Shouldn't these dependencies somehow be handled by the compiler/linker?
Why is the programmer bothered with it? There could be a default
"implementation" that would be used in these cases. Now the programmer
has to investigate in the concept *and* how Lazarus/FPC handles it. Not
very convenient.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 19:41:02 +0200
Jürgen Hestermann <[hidden email]> wrote:

> Mattias Gaertner schrieb:
>  > The hint was about a tool that reduces the burden of knowing to
>  > which package a unit belongs, search paths and dependencies.
>
> Why is this at all necessary? I don't get it of what use such a
> complicated and error prone construct like packages should serve for if
> it is not rock solid. Is this an improvement over simple to use units?
> In units, all dependencies are automatically(!) resolved by the
> software. Why is this impossible for packages? I was not even aware that
> I used a package. I just used a unit (grids).

In Lazarus packages are groups of units. This is not only useful for big
projects, it makes sharing code easier in general. Each
package has its own compiler options. For example the LCL units need
some flags like inlining and C style operators and some linker options.
When you copy a package to another machine you don't have to adapt any
search paths or compiler options.
When some compiler option changes or a sub directory is renamed or the
package is moved to another location on you disk, you don't have to
adapt all your projects that uses the package.
Packages allow to share ppu files. You don't have to recompile
the LCL for every project. Each package has its own directory where its
ppu files are stored.

And packages can do more than compiling. For example documentation and
translation.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Mattias Gaertner
In reply to this post by Jürgen Hestermann
On Sat, 31 Mar 2012 19:41:05 +0200
Jürgen Hestermann <[hidden email]> wrote:

> Mattias Gaertner schrieb:
>  > You made the mistake to use grids without an implementation (e.g. LCL
> interfaces).
>
> Implementation? What's this again? It's no longer enough to use a unit?
> Sorry, but it seems that there is a very steep learning curve even for
> former (Turbo..) Pascal programmers.

AFAIR Turbo Pascal was pretty simple. I really liked it.
It supported only one target platform and the OOP came with
Delphi.
Compare the compiler flags of TP and FPC. TP is a toy compared to FPC.


> I have to learn a lot just to be able to program with Lazarus. It seems
> to be for long term nerds only.
> It has become nearly as complicated as C and relatives.
>
>
>  > I'm not sure what you did not understand about the concept of
> "abstract method".
>
> Everything. If it leads to such results this concept seems to be not
> very good.

"Such results"?

The normal user creates a LCL application and everything is setup for
him.

You didn't use the tools, but instead set up your project manually.
And now you expect that the compiler/IDE magically scans your brain to
find out what your intention was and complete what you have started?

This is like installing Gentoo Linux and then whining about Linux is so
complicated and only for nerds.

 
>  > The LCL "interfaces" is just one possible implementation. Theoretically
>  > you can implement another one. At the moment the LCL unit "interfaces"
>  > is the only supported one.
>
> Shouldn't these dependencies somehow be handled by the compiler/linker?

They are handled automatically if you let the IDE help you.


> Why is the programmer bothered with it?

Because you choose to. I bet most Lazarus users have never
seen this linker error.


> There could be a default
> "implementation" that would be used in these cases. Now the programmer
> has to investigate in the concept *and* how Lazarus/FPC handles it. Not
> very convenient.



Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Strange dependency of units

Žilvinas Ledas
In reply to this post by Jürgen Hestermann
Hello,


On 2012-03-31 20:41, Jürgen Hestermann wrote:

> Mattias Gaertner schrieb:
> > You made the mistake to use grids without an implementation (e.g.
> LCL interfaces).
>
> Implementation? What's this again? It's no longer enough to use a unit?
> Sorry, but it seems that there is a very steep learning curve even for
> former (Turbo..) Pascal programmers.
> I have to learn a lot just to be able to program with Lazarus. It
> seems to be for long term nerds only.
> It has become nearly as complicated as C and relatives.
>
>
> > I'm not sure what you did not understand about the concept of
> "abstract method".
>
> Everything. If it leads to such results this concept seems to be not
> very good.
My observation from the conversation till now: I believe you should
learn a bit about Object-oriented programming and its concepts (abstract
methods being one ot them).
This should let you use Object Pascal language much more easily.


Best regards,
Žilvinas Ledas

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
1234