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 E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...