tags:

views:

202

answers:

2

How to set "Directories/Conditionals" in Project Options and "Library" path in Environment Options? Delphi help don't say much about these very important settings. I have all kind of strange errors because of wrong dependencies between my VCLs.

1.

I have merged a large set of 3rd party controls in a package called ThirdPartyPackages_D7.dpk. This is useful when I reinstall Delphi because I don't have to reinstall all those 3rd party VCLs amnually.

Then, I have my own controls in MyControls_D7.dpk which depends on the ThirdPartyPackages VCL. I also have another package BlgPackage.dpk that depends on MyControls.

At the end of the chain is my application application (DPR project) which is using the controls in BlgPackage.

ThirdPartyPackages.dpk -> MyControls.dpk -> BlgPackage.dpk -> MyApplication.dpr

When I change/edit something to the second package (MyControls.dpk) and build the DPR application, it works. The compiler sees the changes made into that package. However, if I close the project and load and compile the BlgPackage, it throws a nasty message that function xyz cannot be found in MyControls because I delete it (I have loaded MyControls' units into IDE in parallel with application's units). It seems that building the application only refreshes the DCU files for all used packages but not the DCP/BLP files.

How do I write and compile the code in the packages without explicitly loading the packages into the IDE and building them? (Note: I have a nasty bug that does not allow me to switch between projects without restarting the IDE or to load a group of projects/packages (*.bpg) at the same time.)

2.

Another problem is that I want to store the compiled files (DCP/BPL/DCU) of a package in its folder (for example c:\MyProjects\Blg).
If I set the "Output directory", "Unit output directory" and "DCP output directory" boxes of BlgPackage package to its folder, not only its BPL/DCU/DCP files will be stored there but also the BPL/DCP files of MyControls will be stored there. How can I have the binary files of each package in a separate folder?


Delphi 7, Win XP, all projects set to "Rebuild as needed"

+1  A: 
  1. You should explicitely compile packages - just compiling package files is not enough and as you have noticed leads to problems. In modern Delphi versions you can create a project group (not sure about Delphi 7) that contains an application and packages you want to develop with the application, and you can easily switch between them and complile packages without need to close/reopen the application.

  2. BlgPackage should not have an access to MyControls package sources (through "Library" path or by using the same directory), it should access only already compiled MyControls package, else the files from MyControls are compiled every time you build BlgPackage and the compiled files are stored in BlgControls DCU directory


ADDED

The "Library" path should lead to compiled files (.dcp, .dcu) and (if needed) resource files (.res, .dfm) only - it is enough to compile applications and packages that requires "MyControls" package. You can set the directory for compiled files directly in the package settings, and you should copy the resource files (if you need them) to the same directory manually. This directory should be included into "Library" path, or else you can use a directory already contained in "Library" path.

The "Library" path should not lead to source files (.pas) if you don't want these files to be compiled every time you build your BlgPackage or an application that requires "MyControls" package.

Serg
@Serg-I don't think the No2 will work. The Delphi 7 help says this: " If you try to build your package with a file not on the library path, you will receive a compiler error". So, I won't be able to compile my package if I remove its path from Library.
Altar
I did that and now I cannot compile the project. I cannot find one of the DCUs. That DCU belongs to MyControls. It is located in the same folder where the MyControls PAS files are.
Altar
@Altar - storing .dcu in the same folder as .pas is a bad practice and should be avoided. DCU's should be available through "Library" path, while sources (.pas) normally are not.In any case you can copy the DCU that causes problems to the folder available through "Library" path manually, if for some reason you don't want set DCU path in the package options.
Serg
Hi Serg. As explained, separating the PAS and DCU files will make my project not to compile. Many others says (like you) that separating the files will increase the compile speed. I would like that. But in my case it just doesn't work.
Altar
+2  A: 

I use much simpler way for 3rd partie components and reinstalling Delphi.

  • Open regedit and find [HKEY_LOCAL_MACHINE/SOFTWARE/Borland/Delphi/xxx] where xxx is version and export whole branch.
  • Open file and delete keys LMKEY, LMLIC.
  • Copy C:\Program Files\Borland\Delphi x\Projects\Bpl folder to another location
  • Copy C:\Program Files\Borland\Delphi x\Imports to another location
  • Reinstall Delphi including any updates and GExpert
  • Import previously saved registries
  • Restore Bpl And Imports Folder

And whoala, Delphi is back with all 3rd partie components and IDE settings. Only limitation is that all components must reside in same folder before and after reinstalling Delphi.

This also restores TeamSource settings. If you are reinstalling Windows as well, be sure to make windows user with same user name as before.

Ljubomir Đokić
I am using this 'hack' for years. Thanks anyway. +1 as others may use it. PS: Don't forget about the HKCU key (same location: /SOFTWARE/Borland/Delphi/xxx). I guess LMKEY is HKLM but what is LMLIC ?
Altar
LMKEY and LMLIC are licence information about Delphi and if you restore them as well then Delphi would think it is not licensed or something like that.
Ljubomir Đokić