Loading Packages in an Application

From RAD Studio
Jump to: navigation, search

Go Up to Runtime Packages


You can dynamically load packages by using either of the following procedures:

To load packages using the Project > Options dialog box

  1. Open or create a project in the IDE.
  2. Choose Project > Options > Packages > Runtime Packages.
  3. Enable the Link with Runtime Packages check box.
  4. Review the list of known run-time packages in the Runtime package import libraries field. (Run-time packages associated with installed design-time packages are already listed.) Run-time packages are loaded implicitly only when needed (that is, when you refer to an object defined in one of the units in that package).
  5. To enter additional library names, click the Runtime package import libraries entry field and then either:
    • Click the ellipsis Ellipsis that appears at the right-hand end of the field.
      In the Runtime package import libraries dialog box, you can:
      • Enter the name of the new package and click Add.
      • Browse from a list of available packages by clicking the Browse for Folder button on the Runtime package import libraries dialog box. Then click the Browse button next to Package Name in the Add Runtime Package dialog box.
    Note: If you edit the Search Path edit box in Add Runtime Package, you change the Global Library Path.
    • Enter one or more package names in the entry field.
    You do not need to include file extensions with package names (or the version number representing the Delphi release); that is vcl90.bpl in a VCL application is written as vcl. If you type directly into the Runtime Package edit box, be sure to separate multiple names with semicolons. For example:
rtl;vcl;vcldb;vclado;vclbde;

Packages listed in the Runtime Packages edit box are automatically linked to your application when you compile. Duplicate package names are ignored, and if the Link with runtime packages check box is unchecked, the application is compiled without packages.

Run-time packages are selected for the current project only. To make the current choices into automatic defaults for new projects, select the Defaults check box at the bottom of the Project Options page.

Note: When you create an application with packages, you must include the names of the original Delphi units in the uses clause of your source files. For example, the source file for your main form might begin like this:

unit MainForm;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;
#include "vcldb.h"

The units referenced in this VCL example are contained in the vcl and rtl packages. Nonetheless, you must keep these references in the uses clause, even if you use vcl and rtl in your application, or you will get compiler errors. In generated source files, the Form Designer adds these units to the uses clause automatically.

See Also