Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly set "Directories/Conditionals" and "Library" path

Tags:

delphi

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 (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"

like image 287
Server Overflow Avatar asked Sep 07 '10 12:09

Server Overflow


3 Answers

  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.

like image 178
kludg Avatar answered Nov 19 '22 02:11

kludg


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.

like image 40
Ljubomir Đokić Avatar answered Nov 19 '22 00:11

Ljubomir Đokić


MY solution (kinda dirty, but hey it works):

I put ALL 3rd party libraries.controls in a single package (a super-package). I put all my controls in a single package.

Now, when I migrate the packages to a different PC all I have to do is to copy/paste two folders and set two paths.

Works for me - others may not agree with it and I can't blame them. I blame the 'hell designers' from Borland/Embarcadero. If you look on StackOverflow you will see that until now nobody provided an elegant solution to this.

like image 1
Server Overflow Avatar answered Nov 19 '22 00:11

Server Overflow