I have a Delphi project group consisting of three projects: Sales, Inventory, and Orders.
In the Sales project, there is a unit called Customers.pas. The Inventory project has a unit called Products.pas that imports Customers from the Sales project. The Orders project has both Sales and Inventory listed in the requires clause of the Orders.dpk file, and Customers is also imported in the OrdersUnit.
However, when I try to compile the project, I get the following error:
[dcc32 Error] Orders.dpk(42): E2199 Packages 'Sales' and 'Inventory' both contain unit 'Customers'
What could be causing this error, and what is the possible solution? I cannot move, delete or rename any files in the codebase.
It is clear from the error that the Sales and Inventory packages are both linking in their own copies of the
Customersunit, despite your claim that "The Inventory project ... imports Customers from the Sales project".As such, when the Orders project links in both packages, it ends up with 2 separate copies of the
Customersunit, which is not allowed.The
Customersunit MUST be implemented in a single package only. Any other projects that want to use that unit in the same process at runtime MUST import that unit from that package.Your Inventory project is clearly not importing the
Customersunit correctly. For instance, ifCustomers.dcuthat is compiled from the Sales project is visible on the search path for the Inventory project, the compiler will use that DCU while compiling the Inventory project, instead of importing the unit from the Sales package. Make sure that is not the case.