00 Votes

Delphi: Add Path to Library or Unit for all Projects

Question by Guest | Last update on 2024-01-01 | Created on 2017-10-25

I have some Delphi libraries and units (partly self-written, partly also third-party components) that I want to use in more than one of my Delphi projects.

It is quite awkward and cumbersome to add all paths, units and directories again and again for each project. Is there any possibility to do that for all projects at once? In other words, I want to define and make Delphi to first search a list of folders for missing units before it complains that a unit is not existing.

ReplyPositiveNegative
0Best Answer2 Votes

Yes, you can do that with Delphi. There are so-called search paths that can be defined. Delphi is searching those directories for units.

You can adjust those paths like you want and you can add own folders. Here is how to do that:

  1. Go to the Delphi's menu: Tools > Options
  2. A window opens with all settings. Select Environment Options > Delphi Options > Library - Win 32 from the site (the exact names of the menus may differ depending on your Delphi version).
  3. The window displays an overview of different paths (search paths). For us, the specifications behind "Library Path" is interesting. Here, all directories are listed that are searched for units by Delphi. Multiple directories can be separated with a semicolon (;). Just add the folder or the directories containing your libraries to this list.

y default, in my Delphi version, the folder $(BDS)\Imports is defined here. With $(BDS) you are referencing the installation directory of Delphi, in this case the folder "Imports" under it, which my Delphi version is using for imports standardly.

An example for multiple Search Paths would be:

$(BDS)\Imports;$(BDS)\Imports\MyLib;C:\Folder\MyUnitsits

With this settings, the default folder "Imports" under the installation directory will be searched, but also the folders "MyLib" in this directory as well as the additional folder "C:\Folder\MyUnits", in which you probably have stored some own units.
Last update on 2024-01-01 | Created on 2017-10-25

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.