2
votes

I have this error:

E2411 Unit %s in package %s refers to unit %s which is not found in any package. Packaged units must refer only to packaged units (Delphi)

Delphi Help is extremely helpful and it says:

No further information is available for this error or warning.

Why I can't refer to a unit that is not part of a package?

UPDATE:

Never-ending story: Putting the file in its own package breaks something else: Unit GIFImg was compiled with a different version of CCR.Exif.Consts.SOutOfResources This is why I wanted NOT to put the file in its own package.

2
Hi David. I have seen the message. But I want to understand why is that. Why the compiler cannot include an external DCU in my package?External Server Error
@DavidHeffernan well, it could do with some clarification. As it stands it is dangerously close to a circular definition.Marjan Venema

2 Answers

4
votes

You can't refer to a unit that is not part of a package because a package needs to be a self-contained piece of software. That means that a package must contain all units it uses or have them available through packages in its requires clause.

To solve this error you can either

  • include the unit in the package that you are building, or
  • add the package which contains that unit to the requires list of the package you are building.
2
votes

Your question seems to be

Why does the compiler emit this error?

If you refer to unit A then that reference to unit A needs to be resolved. If it cannot be found in the current package, or another package in the requires clause, then the compiler simply cannot proceed.

You also ask:

Why the compiler cannot include an external DCU in my package?

You can simply add the unit to your package in the contains clause of your .dpk file.