Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-08

How to configure IDE for my own libraries?

10 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Frank Church

I have now begun using some of my own files regularly in my projects and I need to store them in one place rather than copy them to every project's folder.

I have created a folder called m:\lazaruslibs\mylib with the source in ..\sources and units in ..\units.
In the Compiler Options for the project, on the Paths tab I have added m:\lazaruslibs\mylib\units to the Other Unit Files (-Fu) box and added m:\lazaruslibs\mylib\units to the Other Sources (.pp/.pas, only used by IDE,not by compiler) box.

It is working fine but I is there a way to configure things in such a way that it is present in every project without having to add it everytime, like it is automatically present in the IDE?

Frank Church ======================= http://devblog.brahmancreations.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100830/52b332dc/attachment.html>

Reply by email

Sven Barth
to Frank Church
Frank Church wrote 15 lines
I have now begun using some of my own files regularly in my projects and I need to store them in one place rather than copy them to every project's folder. I have created a folder called m:\lazaruslibs\mylib with the source in ..\sources and units in ..\units. In the Compiler Options for the project, on the Paths tab I have added m:\lazaruslibs\mylib\units to the Other Unit Files (-Fu) box and added m:\lazaruslibs\mylib\units to the Other Sources (.pp/.pas, only used by IDE,not by compiler) box. It is working fine but I is there a way to configure things in such a way that it is present in every project without having to add it everytime, like it is automatically present in the IDE?

In trunk version you can set your project settings as default ones, thus you add your paths and save your settings so that they are used for every new project.

Another possibility (preferred by me) is to add your units to a package and to include your package with every project. To simplify this you might create a new project template which includes your package by default (I don't know how to do that, though. You might search in the Wiki or look at the fpGUI project which includes such templates)

Regards,
Sven

Reply by email

Frank Church
to Sven Barth
Sven Barth wrote 25 lines
Am 30.08.2010 09:41, schrieb Frank Church: > I have now begun using some of my own files regularly in my projects and > I need to store them in one place rather than copy them to every > project's folder. > > I have created a folder called m:\lazaruslibs\mylib with the source in > ..\sources and units in ..\units. > In the Compiler Options for the project, on the Paths tab I have added > m:\lazaruslibs\mylib\units to the Other Unit Files (-Fu) box and added > m:\lazaruslibs\mylib\units to the Other Sources (.pp/.pas, only used by > IDE,not by compiler) box. > > It is working fine but I is there a way to configure things in such a > way that it is present in every project without having to add it > everytime, like it is automatically present in the IDE? > In trunk version you can set your project settings as default ones, thus you add your paths and save your settings so that they are used for every new project. Another possibility (preferred by me) is to add your units to a package and to include your package with every project.

I am thinking along this line but I don't know how to go about. I usually drag a component onto a project form for the components unit to be added to the file I am working on. My units are source units only, not components. What is the right way to add a non visual package to a project, no components, visual or otherwise, just plain source code? I am yet to build a Lazarus package.

Show quoted text 14 lines
To simplify this you might create a new project template which includes your package by default (I don't know how to do that, though. You might search in the Wiki or look at the fpGUI project which includes such templates) Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Frank Church ======================= http://devblog.brahmancreations.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100830/a43da6a6/attachment.html>

Reply by email

Vincent Snijders
to Frank Church

2010/8/30 Frank Church :

Show quoted text 30 lines
On 30 August 2010 08:50, Sven Barth wrote: > > Am 30.08.2010 09:41, schrieb Frank Church: >> >> I have now begun using some of my own files regularly in my projects and >> I need to store them in one place rather than copy them to every >> project's folder. >> >> I have created a folder called m:\lazaruslibs\mylib with the source in >> ..\sources and units in ..\units. >> In the Compiler Options for the project, on the Paths tab I have added >> m:\lazaruslibs\mylib\units to the Other Unit Files (-Fu) box and added >> m:\lazaruslibs\mylib\units to the Other Sources (.pp/.pas, only used by >> IDE,not by compiler) box. >> >> It is working fine but I is there a way to configure things in such a >> way that it is present in every project without having to add it >> everytime, like it is automatically present in the IDE? > > Another possibility (preferred by me) is to add your units to a package > and to include your package with every project. I am thinking along this line but I don't know how to go about. I usually drag a component onto a project form for the components unit to be added to the file I am working on. My units are source units only, not components. What is the right way to add a non visual package to a project, no components, visual or otherwise, just plain source code? I am yet to build a Lazarus package.

Add the package as requirement in the project inspector.

Vincent

Reply by email

Andreas Schneider
to Frank Church: I am thinking along this line but I don't know how to go about. I usually drag a…

On Mon, 30 Aug 2010 09:05:46 +0100, Frank Church

I am thinking along this line but I don't know how to go about. I

usually

Show quoted text 7 lines
drag a component onto a project form for the components unit to be added to the file I am working on. My units are source units only, not components. What is the right way to add a non visual package to a project, no components, visual or otherwise, just plain source code? I

am

yet to build a Lazarus package.

Then you could also add it to the search path in your fpc.cfg (add another

-Fu line). That way it works in /every/ program you compile. No need to

specify packages or anything else.

Best Regards,

Andreas.

Reply by email

Mattias Gaertner
to Andreas Schneider
Show quoted text 28 lines
On Mon, 30 Aug 2010 09:05:46 +0100, Frank Church wrote: > I am thinking along this line but I don't know how to go about. I usually > drag a component onto a project form for the components unit to be added > to the file I am working on. My units are source units only, not > components. What is the right way to add a non visual package to a > project, no components, visual or otherwise, just plain source code? I am > yet to build a Lazarus package. Then you could also add it to the search path in your fpc.cfg (add another -Fu line). That way it works in /every/ program you compile. No need to specify packages or anything else.

Beware: Only put search paths to ppu files in the fpc.cfg, do not add search paths to sources. You risk creating multiple ppu files.

Mattias

Reply by email

Sven Barth
to Frank Church: I am thinking along this line but I don't know how to go about. I usually drag a…
Frank Church wrote 10 lines
Another possibility (preferred by me) is to add your units to a package and to include your package with every project. I am thinking along this line but I don't know how to go about. I usually drag a component onto a project form for the components unit to be added to the file I am working on. My units are source units only, not components. What is the right way to add a non visual package to a project, no components, visual or otherwise, just plain source code? I am yet to build a Lazarus package.

A package can contain source only units as well. It does not need to register a component nor do you need to install it in the IDE (if you don't want any components visible in the package palette).

Just create a new package, add your units to it and save it (e.g. in the directory where your source files reside).

Now open a project of yours or create a new one and add your package as a requirment. Done.

Regards,
Sven

Reply by email

Frank Church
to Sven Barth
Sven Barth wrote 26 lines
Am 30.08.2010 10:05, schrieb Frank Church: Another possibility (preferred by me) is to add your units to a > package and to include your package with every project. > > > I am thinking along this line but I don't know how to go about. I > usually drag a component onto a project form for the components unit to > be added to the file I am working on. My units are source units only, > not components. What is the right way to add a non visual package to a > project, no components, visual or otherwise, just plain source code? I > am yet to build a Lazarus package. > A package can contain source only units as well. It does not need to register a component nor do you need to install it in the IDE (if you don't want any components visible in the package palette). Just create a new package, add your units to it and save it (e.g. in the directory where your source files reside). Now open a project of yours or create a new one and add your package as a requirment. Done.

When you put a number of files in a package will the units that are not used by compiled into the program?

Show quoted text 9 lines
Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Frank Church ======================= http://devblog.brahmancreations.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100901/66a684af/attachment.html>

Reply by email

José Mejuto
to Frank Church

Hello Lazarus-List,

Wednesday, September 1, 2010, 11:21:54 PM, you wrote:

FC> When you put a number of files in a package will the units that are not used FC> by compiled into the program?

If they do not have initialization or finalization sections, and no functions are being used I think they are compiled but not linked in.

The initialization and finalization usually introduce non expected code in the final program. Example, think in an unit like:

-------------------------------
unit DoNothing

uses someuses...;
type
  TMyUselessObject=class(TObject);
    T: TreeView;
  end;
var
  MyUselessObject: TMyUselessObject;
initialization
  MyUselessObject=nil;
-------------------------------

The simple reference in the initialization pulls in all the code in the unit related to TMyUselessObject even when you do not use TMyUselessObject in you code. And as TMyUselessObject uses a TreeView (in example) all the TreeView code is pulled in, which finally will pull in almost all the LCL even if your code does not use 'm quite sure about this, but maybe a more authorized voice can confirm.

PS: I'm not sure about non referenced global arrays or variables :-?

Best regards, Jos?

Reply by email

Sven Barth
to José Mejuto
Jos? Mejuto wrote 41 lines
Hello Lazarus-List, Wednesday, September 1, 2010, 11:21:54 PM, you wrote: FC> When you put a number of files in a package will the units that are not used FC> by compiled into the program? If they do not have initialization or finalization sections, and no functions are being used I think they are compiled but not linked in. The initialization and finalization usually introduce non expected code in the final program. Example, think in an unit like: ------------------------------- unit DoNothing uses someuses...; type TMyUselessObject=class(TObject); T: TreeView; end; var MyUselessObject: TMyUselessObject; initialization MyUselessObject=nil; ------------------------------- The simple reference in the initialization pulls in all the code in the unit related to TMyUselessObject even when you do not use TMyUselessObject in you code. And as TMyUselessObject uses a TreeView (in example) all the TreeView code is pulled in, which finally will pull in almost all the LCL even if your code does not use LCL at all. I'm quite sure about this, but maybe a more authorized voice can confirm. PS: I'm not sure about non referenced global arrays or variables :-?

Let's describe this a bit easier (without smartlinking):

All units in a package are compiled, but only units that are directly (in uses clause of one of your project units) or indirectly (in uses clause of a package unit which is used by your program) used by your program are linked into the resulting binary.

Example:
You have a package that contains the following units:
- UnitA (uses no units of the package)
- UnitB (uses UnitC)
- UnitC (uses no units of the package)
- UnitD (usen no units of the package)

Now you have a program that uses the units UnitA and UnitB. Thus the units UnitA, UnitB and UnitC are linked into your program, but UnitD is not.

Don't interpret to much "magic" into the packages of Lazarus. It's the same as a unit search path, but automatically managed by the IDE and only compiled if needed.

Is it clear now?

Regards,
Sven

Reply by email