Recent

Author Topic: How to make units/libs available to all projects like in Delphi?  (Read 5597 times)

snorkel

  • Hero Member
  • *****
  • Posts: 817
Hi,
Currently I am using libs like Synapse,SQLite Wrapper and SuperObject, none of these are visible components and for each new project I have to add them to the project options/Compiler Options/Other Unit Files

Is there a way to have a global Paths like in Delphi that applies to all existing and future projects?  I have only recently started using Lazarus instead of Delphi for a lot of things and love but I don't know everything about it yet :-(

Thanks,

Snorkel
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: How to make units/libs available to all projects like in Delphi?
« Reply #1 on: July 27, 2012, 09:44:07 pm »
Assuming the relative path to the libs are the same for all your project, you can go to project options -> paths, fill in the correct paths, then check the checkbox "Use these compiler options as default for newprojects" and save.

Now all your new projects have the correct paths.

All my Lazarus projects reside in a subfolder of /path/to/lazdev/, so this works perfectly for me on all my 2 Windows and 1 Linux setup.

If the relative paths for new projects isn't the same, you can include the paths as absolute paths.
The disadvantage is that when compiling the project on a different machine or OS, the absolute paths are probably wrong and need correcting.


Bart


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11444
  • FPC developer.
Re: How to make units/libs available to all projects like in Delphi?
« Reply #2 on: July 27, 2012, 10:08:17 pm »
I haven't tried it, but the package system of Lazarus is potentially better than Delphi here:

1) Stuff all your general units into a non visual package
2) compile it and install it into Lazarus.
3) let your projects depend on that package.

This has several advantages:
1) the dependency in the project is on the package, not on an absolute path.
2) it's only one dependency on the package, not multiple paths.

You can even add a version number to the (super) package name, and e.g. upgrade
the version of the superpackage used in a project by simply deleting the old (e.g. superpackage102)
dependency and adding the new one. Being able to have multiple sets of these libraries in one Lazarus installation.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to make units/libs available to all projects like in Delphi?
« Reply #3 on: July 27, 2012, 11:32:06 pm »
Put it in fpc.cfg.

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: How to make units/libs available to all projects like in Delphi?
« Reply #4 on: July 28, 2012, 01:43:54 pm »
Put it in fpc.cfg.

Then one has to update fpc.cfg after every Lazarus upgrade because the old customized fpc.cfg is likely to be overwritten after the upgrade.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: How to make units/libs available to all projects like in Delphi?
« Reply #5 on: July 28, 2012, 02:44:00 pm »
Put it in fpc.cfg.

IIRC compiling works, but code-tools cannot find the units...?

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to make units/libs available to all projects like in Delphi?
« Reply #6 on: July 28, 2012, 03:01:30 pm »
Quote
IIRC compiling works, but code-tools cannot find the units...?
Yes, since codetools needs to find the source code. If it's the intention I think the only easy way is to create a project template with the paths (or better, create a package and add it to the project dependency).

 

TinyPortal © 2005-2018