Often it is useful to have 3rd party components part of a repository so it is easier to increase portability.
For instance when you want to include or exclude some of them in certain projects by installing/deinstalling them to/from the IDE.
This can be useful for cases where components bite each other, or you want to vary the components in use by version without spinning up new VMs (Delphi registration counts can be a pain for new VMs; you need to be very careful as you can never decrease your registration count).
I usually do this by having 3 batch files:
- copy from an installed 3rd party library to a repository in a relative way
- register any needed relative files into the IDE
- unregister any needed relative files in from the IDE
If successful, I can uninstall the library.
I especially take this approach with 3rd party libraries that stuff to global places (inside the Delphi installation directory, or worse, inside the Windows directories).
That way, I can try to ensure that compilation of running only uses files from the repository, making my options for portability larger.
Examples I did this for are for instance QuickReports and ODAC.
Some bits are tricky to get right, especially loading dependencies.
It helps to understand that for executable files Windows also searches for dependencies in the directory of the executable file.
For libraries, that does not happen. Which means that if a BPL has dependencies, they either have to be explicitly loaded before (for instance by being in the Known Packages registry entries), or on the search PATH.
Delphi has the %BDSCOMMONDIR% directory in the search PATH. It usually points to “%PUBLIC%\Documents\Embarcadero\Studio\%ProductVersion%\Bpl” (where ProductVersion=19.0 for Delphi 10.2 Tokyo).
There might be a away around this using manifests, but this means modifying the BPL files, which is beyond the point of having these copy scripts.
More on those environment variables in a later blog post.
Related:
- [WayBack] Why my Delphi IDE Expert is not initialized when use the “Known IDE Packages” Key? – Oipapio- oipapio.com
- [WayBack] What is the best way to organize multiple Delphi library packages for the project? – Stack Overflow
- [WayBack] Dynamic-Link Library Search Order – Windows applications | Microsoft Docs
- [WayBack] Java LoadLibrary unresolved dependency but dependent dll is in same directory – Stack Overflow
- [WayBack] windows dll notes · numpy/numpy Wiki · GitHub
- [Archive.is] Windows Internals – Mark E. Russinovich, David A. Solomon, Alex Ionescu – Google Books
- Dynamic-link library – Wikipedia
- [WayBack] How can I specify that my DLL should resolve a DLL dependency from the same directory that the DLL is in? | The Old New Thing: Use the manifest.
–jeroen






