[Lazarus] Adding units to a project

David W Noon david.w.noon at ntlworld.com
Wed Mar 4 18:53:36 CET 2009


On Wed, 2009-03-04 at 17:01 +0000, Antonio Sanguigni wrote:

> I know I'm lost in a glass of water but I cannot be able to use some units.
> I'm building a new lazarus project and I would like to re-use other
> units in my file system. So I added them to this new project with
> Project inspector - Add - Add Files - Add file to packages and this
> operation add the units on .lpr files of project and that's fine. Now,
> I need to use this added unit also in other unit's use clause of the
> project but Lazarus complains that it cannot find it when I try to
> build it.
> 
> Adding requirements of .lpk files is fine and works smooth.
> 
> My question is: Do I need to create a package to use that units or I'm
> missing something ?

The way I approach reusing common code is to have my common units in
local directories:

   ~/units           -- for code that is not yet considered stable
   /usr/local/units  -- for code that is considered stable

The first of these is added with a -Fu option in my ~/.fpc.cfg file, and
the second is added with a -Fu option in my /etc/fpc.cfg file. These
directories can also be added to your Lazarus compilation options.

Whenever I need to incorporate a unit I simply add its name to the
"uses" clause of the unit that needs to invoke code from the shared
unit. Lazarus seems to find the code when tracing, so it all just seems
to work.

-- 
Regards,

Dave  [RLU #314465]
=======================================================================
david.w.noon at ntlworld.com (David W Noon)
=======================================================================



More information about the Lazarus mailing list