I encountered the following puzzling situation while installing a third-party library, in this case Virtual Treeview, which I will use as an example herein.

After following the installation procedure from INSTALL.txt, the new components appeared in Delphi's component palette, and can be added to a form.

However, building one of the supplied example projects, in this case "Minimal" fails, saying:

'Cannot resolve unit name "VirtualTrees" at line xxx', which is the uses statement in which VirtualTrees is listed.

Congruent with that symptom, in the source code editor, (uses) VirtualTrees, and subsidiary component declarations, were marked with red squiggles, indicating identifier undeclared or not resolved.

The supplied demo project was set to target Windows 32. But puzzlingly, if I switch the target to Windows 64, it will compile.

Installation consisted of:

  1. Unzip the supplied zip file to wherever you locate source packages.

  2. In Delphi, open the project group: File > Open .... VirtualTreeView.groupproj

  3. Once loaded, in the project tree, right click on VirtualTreesD26.bpl > Install.

  4. Add VirtualTreeView's "Source" folder to the Library Path, using "Tools > Options > Language > Delphi Options > Library > Library Path > [...]"

What's allowing the IDE to know about the component, but then failure to compile for Windows 32, yet success for Windows 64?

2 Answers

2
David Heffernan On Best Solutions

Each target has its own library path. You have added the VT paths to the Win64 target, but need to do the same for the Win32 target.

Alternatively, remove the VT paths from the Win64 target search path, and add them instead to the target that applies to all projects, and then they will be inherited by the other projects.

In the options dialog there is a drop down control that allows you to specify the target to which your settings are to be applied.

0
gwideman On

The short answer is that the Library Path was not set correctly. And credit to David Heffernan for pointing that out.

But how and why?

The key piece that I missed was that the Library Settings dialog captures different sets of paths applicable to each of the different platform targets. So at the top of the Library Settings dialog there's a "Selected Platform" dropdown that governs which platform the settings beneath will be applied to.

To be able to build a Win 32 VCL application, the Library Path needs to be set specifically for Windows 32, which means setting the Selected Platform dropdown to Windows 32 before performing the step of adding the path to Virtual TreeView's Source directory.

Obvious in retrospect, and perhaps this SO post will help connect "Cannot resolve unit name" to this potential cause.

There are a couple of gotchas to add regarding why this happens.

a) Users coming from older versions of Delphi may be familiar with this Library Settings dialog before it handled multiple platforms, thus not realize that it now has a "Selected Platform" feature.

b) On my installation of Delphi 10.3, which is a fresh one, that "Selected Platform" dropdown reverts to Windows 64 every time you open the Library Settings dialog. It neither coordinates with the platform of the currently open project, nor does it remember what you last set it to, it seems. So it's easy to miss that it's not set to the platform you assumed, unless you know to look explicitly.

It may also be useful to know that while this functionality sets the library path for the entire Delphi installation ("globally"), there are overlapping settings at the project level, accessed as follows (for the example "Minimal" project):

Project tree, ProjectGroup1 > Minimal.exe > Build Configurations > Right-click > (Project options dialog) Building > Delphi Compiler > Target (All configurations, or particular target) > "Search path" slot.

Delphi apparently merges "Search path" with Tools > ... > Library settings > Library path.

Finally, for Virtual Treeview, its maintainer Joachim Marder has added a note to the installation instuctions to avoid the pitfall described here.