Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: Required package not found

I'm trying to build 3 packages, A, B and C. A defines some base classes that are used in B and C. I've got all 3 of them in the same project group, all set up to output to the same custom BPL output folder. This folder is in the search path for B and C. But when I go to build B and C, the compiler chokes on the Requires list. "Required package 'A' not found."

How do I tell B and C where to find A so they'll build correctly?

like image 441
Mason Wheeler Avatar asked Apr 18 '09 19:04

Mason Wheeler


4 Answers

Either the package can't be found, or the compiler is confused. In the later case, a restart sometimes helps. Then a manual build from all packages in order.

If it really can't be found, check if all package (bpl and dcp) and dcu files are available. You need both.

like image 92
Toon Krijthe Avatar answered Nov 17 '22 09:11

Toon Krijthe


If this happens when the IDE is trying to load a package: your package output directory (where the *.bpl files go) has to be on your system's PATH environment variable. Packages are statically linked DLLs, Windows has to be able to find them to load them.

If this happens when building the packages: any/all of your DCP output directories (where the *.dcp files go) have to be in the dependent projects' search path so that the compiler can find the compiled packages. You can also leave the DCP output directory of the package project empty - in which case the global DCP output directory set in Tools\Options\Library is used; the dependent projects then don't need to include it in their search path.

like image 36
Ondrej Kelle Avatar answered Nov 17 '22 11:11

Ondrej Kelle


It is possible that the name of the required package is incorrectly specified in the 'requires' clause of the package you are trying to compile. Let's take an example:

We have two packages - VirtualTreesR.dpk and VirtualTreesD.dpk. VirtualTreesD requires VirtualTreesR. They both have the '16' suffix, so they both are displayed in the Delphi project manager window as VirtualTreesR16.bpl and VirtualTreesD16.bpl. You may think that these are the names of the packages, but you are wrong. The names of the packages are still VirtualTreesR and VirtualTreesD, not VirtualTreesR16 and VirtualTreesD16.

When VirtualTreesR.dpk is compiled Delphi produces two files (I don't talk about DCUs here) VirtualTreesR*16*.bpl and VirtualTreesR.dcp. See the difference?

Then we attempt to compile VirtualTreesD.dpk and get the error: "[DCC Fatal Error] VirtualTreesD.dpk(35): E2202 Required package 'VirtualTreesR16' not found".

The error happens because the 'requires' clause of the VirtualTreesD.dpk package contains the following lines:


    requires
      designide,
      VirtualTreesR16;

Delphi tries to find VirtualTreesR16.dcp and fails even if the Delphi search path and the PATH environment variable are set correctly because there is no VirtualTreesR16.dcp. Only VirtualTreesR.dcp.

The solution is to fix the 'requires' clause so it will look like the one below:


    requires
      designide,
      VirtualTreesR;

Hope it helps.

P.S. This a quite frustrating issue because this name mismatch is not obvious and its fragments are scattered across different settings. Delphi could be more specific if it specified what file exactly it tried to find (e.g. 'VirtualTreesR.dcp' instead of 'VirtualTreesR').

like image 2
Karakurt Avatar answered Nov 17 '22 11:11

Karakurt


I would check to make sure where you are writing the .dcp files for the packages. once you have this, check that the search path of each package has an entry for the .dcp output folder.

like image 1
MikeJ Avatar answered Nov 17 '22 11:11

MikeJ