Delphi Error – E2201 Need imported data reference ($G) to access ‘%s’ from unit ‘%s’

Delphi Compiler Error

E2201 Need imported data reference ($G) to access ‘%s’ from unit ‘%s’

Reason for the Error & Solution

The unit named in the message was not compiled with the $G switch turned on.

(*$IMPORTEDDATA OFF*)
unit u0;
interface
implementation
begin
  Writeln(System.RandSeed);
end.

program u1;
  uses u0;
end.

In the above example, u0 should be compiled alone. Then, u1 should be compiled with CLXxx (where xx represents the version). The problem occurs because u0 is compiled under the premise that it will never use data which resides in a package.

(*$IMPORTEDDATA ON*)
unit u0;
interface
implementation
begin
  Writeln(System.RandSeed);
end.

program u1;
  uses u0;
end.


To alleviate the problem, it is generally easiest to turn on the $IMPORTEDDATA switch and recompile the unit that produces the error.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...