E2201 Need imported data reference ($G) to access '%s' from unit '%s' (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

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.