25

In Delphi XE2, I have a single control in a pair of design/run time packages. Originally, everything was working fine. I've built each of them many times already. Suddenly without warning, the design time package started complaining in one of my units that the Graphics unit is missing when I build. Graphics is a standard unit, but it's not found from this one place. I haven't even made any changes to this unit, and as far as I know, any changes that could affect this.

Here's just the uses at the top (interface) of this unit:

uses
  Graphics, ColorConv, Classes, Dialogs, ZLib;

As you can see, it's a very simple unit, and I only make very simple changes to this project. What could make it start complaining about this out of nowhere?

The strange thing is that it all works fine if I install it, it just doesn't build.

There's quite a bit of code, and I'd hate to have to post the entire thing.

2
  • 4
    @Downvoter: Please explain how this is "not useful"? Commented Jan 10, 2012 at 15:13
  • 3
    +1. You're surely not the only one in the same situation and it will certainly help others when they move to XE2.
    – Francesca
    Commented Jan 10, 2012 at 18:21

3 Answers 3

33

Wild guess: it needs the Vcl. namespace prefix?

4
  • 1
    That did it - I'm new to the namespace prefixes :D Commented Jan 10, 2012 at 1:27
  • 18
    You don't need to add the Vcl. prefix in code if you make sure Vcl is included in the Unit Scope Names list in the Projct Options instead. Commented Jan 10, 2012 at 2:30
  • @PresleyDias XE2 introduces Firemonkey, along with some other new goodies. With these changes, it was necessary for Embarcadero to add these prefixes so you can define which of the set of units to use. For example, Vcl.Graphics vs FMX.Graphics (I don't know if that's a real comparison, but just an example) Commented Jan 10, 2012 at 17:03
  • @JerryDodge, Ok got the idea about the prefix, nice example Commented Jan 14, 2012 at 6:19
9

if there are several declaration of graphics(or other VCL units like:controls,forms ...)in your project, you can add VCL namespace to your project
as follows:

project menu-->options-->delphi compiler->>add in "unit scope names" value "Vcl"

5

Check your paths in Tools->Options->Environment Options->Delphi Options->Library, in particular the Library Path and Browsing Path settings. The defaults for my installation of XE2 (excluding those added by third-party components and my own stuff):

Library:

c:\program files (x86)\embarcadero\rad studio\9.0\lib\Win32\release;c:\program files (x86)\embarcadero\rad studio\9.0\Imports;C:\Users\Public\Documents\RAD Studio\9.0\Dcp;c:\program files (x86)\embarcadero\rad studio\9.0\include;

Browsing:

$(BDS)\SOURCE\VCL;$(BDS)\source\rtl\common;$(BDS)\SOURCE\RTL\SYS;$(BDS)\source\rtl\win;$(BDS)\source\ToolsAPI;$(BDS)\SOURCE\IBX;$(BDS)\source\Internet;$(BDS)\SOURCE\PROPERTY EDITORS;$(BDS)\source\soap;$(BDS)\SOURCE\XML;$(BDS)\source\db;$(BDS)\source\Indy10\Core;$(BDS)\source\Indy10\System;$(BDS)\source\Indy10\Protocols;$(BDS)\source\fmx;$(BDS)\source\databinding\components;$(BDS)\source\databinding\engine;$(BDS)\source\databinding\graph;$(BDS)\source\fmi;$(BDS)\source\data;$(BDS)\source\data\ado;$(BDS)\source\data\bde;$(BDS)\source\data\cloud;$(BDS)\source\data\datasnap;$(BDS)\source\data\dbx;$(BDS)\source\data\dsnap;$(BDS)\source\data\Test;$(BDS)\source\data\vclctrls;

Also, since you're new to XE2, you may want to check to see (outside the IDE) if you have an environmental variable for PLATFORM defined. Some PC manufacturers (HP as a particular example) define this variable on their computers, and it interferes with the IDE's requirements. (The IDE uses PLATFORM as a temporary environmental variable in paths used for different platforms, which fails if there's one predefined outside the IDE.) You can check by opening a command prompt and typing SET PLATFORM and hitting Enter. If there's one pre-defined, it can cause various hard to track down problems; you can remove it safely on every machine I've run across. (Right-click My Computer or Start->Computer, choose Properties, Advanced System Settings, Environmental Variables.)

1
  • Great tips, but other answer fixed my problem :D Commented Jan 10, 2012 at 1:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.