2

I have downloaded a component that has many packages in it, then I have install all the design time packages and generated all the other dcu files.I have to assign its path in Delphi search path every time I create a new application. Is there a way to assign its path to Delphi compiler search path once and all application will get access to these unit, so that I need not to manually set every time the path for a new application.

akash_27
  • 151
  • 1
  • 9

2 Answers2

4

If you want to have some component automatically available for every new projects you need to change the default Delphi IDE options - specifically path locations - so that Delphi IDE knows where to find needed files.

You do this by going into menu Tools -> Options. Then in the TreeView which is used for splitting the options into multiple categories you select Enviroment Options -> Delphi options -> Library.

On the right side of the window you will now have different options regarding the path locations for libraries and source files.

In order to allow Delphi to find needed precompiled units of your component you need to add the folder in which they are located to Library path.

In order to allow Delphi to find source files of your component you need to add the folder in which they are located to Browsing path.

You can read more information about these settings in the Delphi documentation which is also available online here: http://docwiki.embarcadero.com/RADStudio/XE6/en/Library

Note if you don't own Delphi XE6 but one of the previous XE versions simply change the webpage URL by replacing "XE6" with the one you own.

EDIT: I have edited my answer to provide more specific information. Old post below:

If you got to Tools -> Options (or is it Enviroment Options in latest versions) you can set Default options for the Delphi IDE. These options also include the Default path settings which will be automatically used in all new projects.

Uli Gerhardt
  • 13,748
  • 1
  • 45
  • 83
SilverWarior
  • 7,372
  • 2
  • 16
  • 22
  • Is this the Option that you are talking about. Tools -> Options -> Delphi Options -> Library -> Library Path – akash_27 Aug 20 '14 at 12:13
  • I have edited my original answer to be hopefully more clear. But basically yes. – SilverWarior Aug 20 '14 at 13:45
  • Good point about the Library path. I wasn't expecting it to work after reading something here recently which said that in XE4/6 the Library path is only for allowing the compiler + IDE to find packages and DCPs, but I did a test prompted by your answer and it allows the compiler to find DCUs too. – MartynA Aug 20 '14 at 23:14
  • So you ellaborated my answer to make it more clear.Thanks and it worked. – akash_27 Aug 21 '14 at 04:37
  • @MartynA Well the documentation is a bit weak here becouse in documentatio it only says "Specifies search paths where the compiler can find the required files for the package, such as .dcp and .bpi. files." The emphasis is on "such" becouse it only mentiones some file types. But if you ask me it should specifically say which files are searched there. – SilverWarior Aug 21 '14 at 05:52
  • 1
    Note that in latest Delphi versions the location of the library path setting has changed. It is now in "Tools > Options > Language > Delphi Options > Library" – Hans Mar 21 '19 at 15:14
0

The way I do this is to have a folder "Lib2" which I use as the unit output directory whenever I compile/install components - I let the components (I mean their source files, etc) be installed whereever they want).

(I call it "Lib2" because traditionally Delphi has placed its own DCUs in a folder called "Lib", and putting all the third-party ones in a folder separate from that one avoided having to re-install Delphi if my set-up got into a mess.)

If you do that, all you need do for new projects is to include the path to that folder in the project search path and set that as the default search path.

The way to do that varies with Delphi version - the D7 era it was just a question of ticking the "Default" checkbox on the Directories/Conditionals tab of Project | Options. The only minor problem is that sometimes the component needs a resource file; if the compiler complains about that, just copy it to there manually.

In XE4, there are several ways of getting Delphi to find compiled DCUs that you've send to Lib2 or whatever you care to call it:

  • The simplest seems to to do what the other answer suggests, namely add the Lib2 path to the list of Library paths under Tools | Options. The compiler will then use the DCUs it finds there without needing to be able to finds their sources, which is generally a good thing (see "btw" section below).

  • A second way is to create a project "Option Set" (see the OLH for details of what they are and how to create one, and then edit it (again, see OLH) to include Lib2 in the list of search paths. After that, you can apply that Option Set to any project which it suits. There may be a way to automatically apply your Option Set to new projects, but I haven't managed to find it yet. In any case ...

  • A third way is to add a project which has Lib2 amongst its search paths to the Delphi repository and then create new projects that you want to use Lib2's contents from this entry in the repository.

Btw, there is an important practical point to having 3rd party libraries and any of your own standard ones output their DCUs to your Lib2 or equivalent. Because the compiler can find the compiled DCUs there, it does not have to be able to find the source code of those libraries in order to be able to compile your project. Isolating the compiled DCUs in this way helps avoid the dreaded "unit x was compiled with a different version of y" error message (y usually being a bpl) which has been the cause of so many cries for help in Delphi newsgroups over the years.

MartynA
  • 30,454
  • 4
  • 32
  • 73
  • I am looking for a default setting it at all it exist. From your response I still need to provide search path in every application that uses the third component. Your solution reduces the mess of handling many search paths. – akash_27 Aug 20 '14 at 12:10