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.