IceCold
IceCold

Reputation: 21124

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

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.

Upvotes: 2

Views: 1229

Answers (2)

David Heffernan
David Heffernan

Reputation: 612794

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.

Upvotes: 2

Marjan Venema
Marjan Venema

Reputation: 19346

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.

Upvotes: 4

Related Questions