Installing Virtual Treeview

Delphi component’s package installation procedure has always been a mess. If you don’t rely on self-made “automated” installations that just copy compiled binaries and do some registry patches that could easily destroy your Delphi installation beyond repair you should do everything manually from IDE. It takes time, and if you have a lot of packages it takes a lot of time.

To make the situation even worse the package configuration information is now scattered among 3 files – *.dpk, *.dproj and *.res; and these files contains both important package configuration and absolutely irrelevant private information about package developer’s system. As a result package developers usually supply *.dpk file only, leaving it to a package user to create the missing configuration data. And of course you have a lot of chances to forget some important setting…

Well, enough ranting. I have recently reinstalled Windows (and Delphi 2009) on my notebook and now slowly installing component packages. Here is a story of Virtual Treeview package installation. I hope the following will help me next time I install Virtual Treeview package and also help those who install Virtual Treeview package for the first time.

1. Checkout latest Virtual TreeView build from “http://virtual-treeview.googlecode.com/svn/trunk/” to “C:\Packages\VTree” folder.
2. Delete ‘Delphi-deprecated’ subfolder. It is obsolete and about to be removed in some future version.
3. Run Delphi IDE (Delphi 2009 in my case).
4. Open runtime package “c:\Packages\VTree\Packages\Delphi 2009\VirtualTreesR.dpk” (File-> Open Project..). You will be prompted to upgrade the project – click “OK”.

5. Rightclick on “VirtualTreesR.bpl” in the Project Manager panel and select “Options” from the context menu.

Now we should configure the package. First we should select a directory to store the compiled units (*.dcu). We have two options – either to add a new path to “Library Path” list or to use a path already available in “Library Path” list. I prefer the second, so I set “Unit output directory” to $(BDSCOMMONDIR)\Dcp:

$(BDSCOMMONDIR) = “c:\Users\Public\Documents\RAD Studio\6.0” on my system with Delphi 2009.

Next important (and frequently missed) setting is “Symbol reference info”. It should be set to “Definitions only” – otherwise code navigation in package units (Ctrl-Click) will not work.

One more nesessary setting is LIB Suffix; LIB Suffix is 120 for Delphi 2009:

I have made all settings for “Base” configuration. I have not applied any settings to “Debug” configuration, so “Base” and “Debug” configuration are identical and I can use any. To be sure we can check active build configuration in “Configuration Manager” (it is “Debug” by default).

I assume that “Release” configuration is more suitable for Build machine while “Debug” configuration is more appropriate for developer system.

Now we can compile the configured package. Rightclick on “VirtualTreesR.bpl” in the Project Manager panel and select “Compile” … to see the compiler error message:

[DCC Fatal Error] VirtualTrees.pas(461): F1026 File not found: ‘Compilers.inc’

The Virtual Treeview developers’ fault. ‘Compilers.inc’ is lying in “c:\Packages\VTree\Common”. The simplest solution is to copy “c:\Packages\VTree\Common\Compilers.inc” to c:\Packages\VTree\Source\Compilers.inc”

After copying ‘Compilers.inc’ file the package compiles. Now close the runtime package (File-> Close All) and open designtime package “c:\Packages\VTree\Packages\Delphi 2009\VirtualTreesD.dpk”.

Designtime package settings are the same as runtime package settings, with little differences:

Rightclick on “VirtualTreesD.bpl” in the Project Manager panel and select “Compile” … to see the compiler error message again:

[DCC Fatal Error] VirtualTreesReg.pas(8): F1026 File not found: ‘Compilers.inc’

Copy “c:\Packages\VTree\Common\Compilers.inc” to “c:\Packages\VTree\Design\Compilers.inc” and compile again. Now the package compiles OK.

Rightclick on “VirtualTreesD.bpl” in the Project Manager panel and select “Install”:

Close the designtime package (File-> Close All).

We have successfully installed Virtual Treeview components to the component palette, but that is not all. Create new VCL Forms application, drop TVirtualStringTree component on the form and try to compile application:

[DCC Error] E1026 File not found: ‘VirtualTrees.res’

It appears that ‘VirtualTrees.res’ file should be placed in a directory in “Library Path” list. The solution is to copy the file to $(BDSCOMMONDIR)\Dcp. This can be done manually, but it could also be done automatically if, for example, a runtime package was configured with post-build event

copy “c:\Packages\VTree\Source\VirtualTrees.res” “c:\Users\Public\Documents\RAD Studio\6.0\Dcp\VirtualTrees.res”

After copying “VirtualTrees.res” (manually or by recompiling “VirtualTreesR.dpk” with post-build event) the application compiles.

The last thing to do is to enable code navigation – add “c:\Packages\VTree\Source” directory to “Browsing Path”:

That is all for me; someone else may prefer slightly different package settings, I like these.

The thing I don’t like is a lot of tedious mechanical work to install a component package. Installing Virtual Treeview is easy because it is just one runtime and one designtime package; installing dozens of packages is real nightmare. The perfect solution for me is a single standard user-customizable package configuration file supported by Delphi and provided by every component vendor. No stupid mouse clicks in dialogs, just plain text file that you can edit in Notepad and use many times in IDE or with some command-line utility. Well, that is a dream.

Advertisements

7 thoughts on “Installing Virtual Treeview

  1. I completely agree. I have tried (and failed) several times to install Virtual Treeview, and quite a few other packages. After a while I just give up and carry on with components that I have already. And your comment applies not just to Delphi components but many other programs as well. What is even more annoying when the various files needed for the installation are scattered all over the place.

  2. When I learned Delphi package installation was the biggest headache.

    It still is but now I have got used to it. 😉

    I just wish it was something as simple as giving install VCL from source and then selecting the folder where the source resides.

    That is it!

    What do you say?

  3. Also things that are wrong or not the best in your guide:
    Don’t copy any files around, just add the path to the search path of the package. (as said, component designer should have done that)
    The res file has absolutely nothing to do on the dcp folder. If you get the file not found error when compiling a application with the component on it thats a sign that it tries to recompile the components sources. The package should specify some dcu output directory (another thing most component designers do wrong) which you just add to the delphi library path.

  4. “First we should select a directory to store the compiled units (*.dcu). We have two options – either to add a new path to “Library Path” list or to use a path already available in “Library Path” list. I prefer the second, so I set “Unit output directory” to $(BDSCOMMONDIR)\Dcp”

    I prefer the first option – adding a new path to “library path” for both Common and Source directories. This way is mentioned in install instructions very frequently. So compiled dcu-s stay in source dirs if component author didn’t consider to use other dir for that. Usually there are one or two dirs per component. Is something bad with compiling performance or are any other considerations?

    I agree that installation of libraries should be like getting a new one with Nuget in Visual Studio 🙂

    P.S. Thanks for mentioning LIB Suffix in Project Options/Description/Package name. In D2010 it is called Shared object name and Library name in Delphi XE. It’s a good feature and it would be better if you were allowed to put there some conditionals like $Compilerversion to have only one .dpk file which compiles to different package names depending on version of Delphi, wouldn’t it?

    Hmm, if we would have VirtualTreesR.120.bpl how to set what the dependent designer package VirtualTreesD requires without pointing exactly to VirtualTreesR.120.bpl?

  5. @ Concerning adding path to component sources to “Library Path” – I never do it, because I don’t like to rebuild the component sources every time I build application that uses that component. The component may add paths to “Library Path”, that is OK, but it should be paths to compiled binaries (*.dcu, *.dcp) and resources, not to source code (*.pas) IMO.

    @ Concerning VirtualTreesR.120.bpl – the file name is VirtualTreesR120.bpl, the dependent packages ‘requires VirtualTreesR.bpl’ (without 120). That removed 120 from the package name in ‘requires’ is exactly why LibSuffix directive is useful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s