Install Delphi Packages

Writing Delphi Components - Creating and Installing Packages

See menu Component, Install Packages in the IDE. Please make sure to set your Delphi library path correct that it includes the folder where these DCU files. A package is a special dynamic-link library used by applications, the IDE, or both.Runtime packages provide functionality when a user runs an application.Design-time packages are used to install components in the IDE and to create special property editors for custom components.A single package can function at both design time and runtime, and design-time packages frequently work by calling.

If you want your components to have a design time presence (placed on the toolbar and be able to set parameters via the Object Inspector), then they must be placed in a package and installed in the IDE.

Though it is not documented anywhere, you need to know that packages can only be installed in the same version of Delphi that was used to compile them. (The *.dcu files are version dependent.) This means that if you share some component

  • either you release the source code (so it can be installed in any version)
  • or you compile a package in every version of Delphi (including those that are not yet released)

Of course, this brings up the question of how to make components available in C++ Builder. (Maybe I'll figure this out later.)

Installing Components - Single Directory Manual Installation Example, Debugging
Creating a Package Creating a Package Collection
Supporting Multiple Delphi Versions References

Installing Components

You'd think this was documented somewhere. (Actually, the help contains a significant amount of information on this. However, it is very difficult to find and to understand.)

(In the help, you can try Installing component packages. However, it does not mention the required resource file. To find this, search the help for installing components, select Compiling components into packages, and click on Installing component packages.)

To use a unit in another program, all you need is the *.dcu (Delphi Compiled Unit) file. Components are a bit more complicated - they need to be registered so that their icons will be displayed on the toolbar, and they need to execute at design time so that they can paint themselves and make appropriate property assignments.

To accomplish this, you will need at least 2 files in addition to the *.dcu files - PackageName.bpl, and PackageName.dcp. If any of the included units include a resource file (either *.res or *.dcr), then all those files will also be necessary. (See Creating a Package to generate these.)

64114, (816 523 The Intel 8080A is a complete 8-bit parallel central processing unit (CPU). MISSOURI: Kansas City, 8080 Ward Pkwy, Kansas Ci MO. It is fabricated on a single. NOTICE: This is a produc&ion data sheet. This book contains detailed specifications for 111 semiconductor memory. Ferrari

PackageName.dpk, PackageName.dcu, and the *.pas files included in the package do not need to be distributed. (They are used to build the package, they are not needed to use it.)

    Then Install the package using

      Component / Install Packages
    (Install is also a button in the Package dialog box.) Install includes the component buttons on the component tool palette.

    Notes:

    • The *.bpl (Borland package library) file resources can be read by the Resource Hacker.
    • dcl_xxx - Design time Component Library, xxx should identify you or your company
    • Your dcl_xxx.bpl files reference vcl50.bpl.
    • *.dcp and *.dcu files must be in the Delphi Library Path.
    • When present, an *.dpc (package collection) file contains the other files (dcp, dcu, bpl). Therefore, it is the only file needed. (Note that dpc <> dcp.)
    • To add your component to an existing package,
      • Select File / Open.. / *.dpk
      • Add the appropriate source files
      • Press compile

    Single Directory Manual Installation Example

    This assumes that you already have a package and the necessary help files. It also assumes that you want to install all the related files in a single directory (not necessarily the best approach) instead of scattering it around like Borland suggests (has some advantages).
    • Under C:Program FilesBorlandDelphi5, create the directories Packages[PackageName]
    • Enter the directory via Tools / Environment options.. / Library / Library path
      I used - $(DELPHI)Packages[PackageName]
    • Copy [PackageName].bpl and [PackageName].dcp to the new directory
    • Install the package via Component / Install Packages..
      • Press the Add button
      • Select your bpl file (the default directory is C:Program FilesBorlandDelphi5Projects)
      • At this point, the component(s) will be visible in the tool bar and can be placed on a form .. however, the form won't compile
    • For each *.pas file listed in [PackageName].dpk, copy the corresponding *.dcu file to the new directory
    • Copy each *.dcr file listed in [PackageName].dpk to the new directory
    • If there are any actions, copy the associated *.dfm files to the new directory (these contain the icons)
    • Copy the help files (hlp, toc, cnt) to the new directory and install (link) them

    Runtime Packages

    In general, I prefer to build complete exe files that don't use any dll's other than those provided by Windows (and even that is pretty risky). However, if Project / Options.. / Packages / Build with runtime packages is checked, then the [PackageName].bpl file is used (at run time) instead of the *.dcu files (at compile time). Since (at this point) the *.bpl file is not in the windows search path, your program will not run until you add it to the path.

    You can place a copy of the *.bpl file in one of these directories

      Ext Description Comment
      pas Pascal source code Do not need to distribute, but required to step through the code during debug
      dcu Delphi Compiled Unit One for each pas-file. Must distribute if the exe does not call the associated bpl-file(dll-file). (Project / Options.. / Packages / Build with runtime packages is disabled.)

      There is also a dcu-file associated with the dpk-file. How to unlock fl studio 20 from demo mode free. This one should not be distributed.

      bpl Borland package library Run-time dll, must distribute. Also used when Project / Options.. / Packages / Build with runtime packages is enabled.
      dcp Delphi compiled package Must distribute, used at Design-time, contains Design-time code for all the dcu-files
      dpk Delphi package Source file that defines the package. Create via File / New.. /New / Package.
      pce dpc Delphi Package Collection This is a collection of the files needed to install one or more packages. Create this using Tools / Package Collection Editor.
      hlp
      toc
      cnt
      Path on my system Extensions
      C:Program FilesBorlandDelphi5Bin bpl, dll
      C:Program FilesBorlandDelphi5ProjectsBpl its up to you
      C:Program FilesBorlandDelphi5Projects exe (default output directory)
      Same directory as your exe exe (custom output directory)
    or you can modify your system's search path (I don't recommend this).

    In one test case (just a simple form), the exe file was 15 kb using bpl's, and 356 kb using dcu's. (In another test, just a form and no components, it was 14 kb and 298 kb.)

    Debugging

    When developing components, be sure to have the *.dcu file in the search path
      Project / Options.. / Directories / Search path

    In order to debug a component (set break points), the *.dcu and *.pas files should be in the same directory or at least the source file needs to be in the Debug Source Path (Project / Options.. / Directories).

    In order to step through vcl code, the *.dcu files are already in the search path. Therefore, you only need to include the *.pas files in Delphi5SourceVcl in the Debug Source Path.

    It appears that there may be a small difference between machines. Today (5-2003), I had to enable the use of Debug DCUs in order to step through the VCL files - Project / Options.. / Compiler / Use Debug DCUs - and Delphi5SourceVcl was NOT in the Debug Source Path. I don't know how I was able to step through the VCL before.

    Creating a Package

    To place a component on the toolbar, you need to create a package.
    • From the Delphi menu, select
        File / New.. / New / Package
    • In the package window, make sure that Contains is highlighted and click Add. Include all the applicable *.pas files.

      Including *.dcu files (one of the options) seems to have no purpose - it still tries to find the *.pas files when it compiles.

    • Click the Options button
      • On Description tab - the Description should contain a generic identifier that represents your brand and a phrase the describes the package. If this is omitted, then only the filename and path will be displayed when you look at the list of installed packages.
      • On Version Info tab - CompanyName, FileDescription, FileVersion - Though these are stored in only the *.dof and *.res files, they should be entered.
    • Save the package via File / Save. It does not matter if you save the package before or after the files are added, either way, the hideous long path names are used .. I really prefer shorter relative path names. (Delphi 6 uses relative names.)
    • Press Compile to produce *.dcu files for each *.pas file and one for the package itself. It also produces the *.bpl and *.dcp files.
    • Use Install to add the package to the Windows registry and place the components on the toolbar.
    The package definition is stored as plain text in dcl_xxx50.dpk. You can add additional components by editing and recompiling this file. (By convention, I name package files as dcl_[package_ID][Delphi_Version] - dcl - Delphi Compiled Library.)

    By default, your *.bpl and *.dcp files are placed in

    In general, this is good because it is already in the necessary path definitions. However, I prefer to keep everything related to a project in a single directory tree. As a result, I suggest that you change to point elsewhere. (BPL output directory is not available in Delphi 6, but appears to be controlled via PackagesDCP output directory.) I suggest a tree something like

    I have also used this structure

    This will allow you to zip the tree and distribute a smaller file.

    I do not suggest using

    to change the output directories because that will affect all projects .. and only a specific project should be assigned to a directory that is named for it.

    Note: In Delphi 5, the output paths can not be set using the Delphi menu. Instead, you have to manually edit dcl_xxx50.dof (stored in ini file format).

    I have tested this with relative paths, as shown above.

    Creating a Package Collection

    A package collection can contain multiple packages. A package collection contains the required *.dcu files and the optional *.pas and *.res files. It also instructs the installer where to place the files.

    However, because the resulting file is over 2 Mb, and redistributes a file (vcl50.bpl) that should never (IMHO) be redistributed, I do not suggest using this. (vcl50.bpl is required for the package to install .. but it is either already on the developer's machine or the user has the wrong version of Delphi. On the other hand, vcl50.bpl is required on an end user's machine if the application is configured to 'Build with runtime packages'.)

    To create a new collection, from the Delphi menu, select Tools / Package Collection Editor.

    Identify your package collection under Author/Vendor name and add a couple of directories to the Directory list. The Directory name is what appears in the comboboxes. For example

    In the editor, select Add a package from either the menu or the toolbar. Once you've included a package, select Add a file group (it helps a lot if you name your group - it gives you something to click on later). You should probably have several groups - the *.dcu files are mandatory, but you might make the source files optional. Click the Auto.. button to locate ALL the source and/or *.dcu files referenced in the package. Now go through and delete all the Delphi files. (My files were at the bottom of the list. I scrolled to the bottom and selected the first Delphi file above my files. Then, I scrolled to the top of the list, held down the shift key, and clicked the first file in the list. I simply deleted the selected files.)

    I tried removing vcl50.bpl from the package - then it wouldn't compile.

    Supporting Multiple Delphi Versions

    The DCU's made for one version of Delphi won't work in another version.

    That's right - you must recompile your components for each Delphi version. (I don't remember seeing this in any of the references.)

    I tried to install a component compiled in Delphi 5 into Delphi 6 .. an error said that it required vcl50.bpl. So I found that and placed it in C:WINDOWSsystem32, but it is not compatible with vcl60.bpl because they both have the same objects.

    As a result, I had to re-compile the source in Delphi 6.

    Because of this, I recommend that you always include a Delphi version indicator in the package filename.

    This is copied from the Delphi 5 help (from Deploying packages)

      vcl.dcp is required. (go figure) The following excerpts are from various *.dpk files

      References

      • Teach Yourself Borland Delphi 4 in 21 Days, good reference.
        Creating Components is very good.
      • DelphiByDesign
      • Developing Custom Delphi Components
      Author: Robert Clemenzi - clemenzi@cpcug.org
      URL: http:// cpcug.org / user / clemenzi / technical / Languages / Delphi / Packages.html
      Description
      You can also load a package at runtime by calling the LoadPackage function. LoadPackage loads the package specified by its name parameter, checks for duplicate units, and calls the initialization blocks of all units contained in the package. For example, the following code could be executed when a file is chosen in a file-selection dialog.
      A package is a special dynamic-link library used by applications, the IDE, or both. Runtime packages provide functionality when a user runs an application. Design-time packages are used to install components in the IDE and to create special property editors for custom components. A single package can function at both design time and runtime, and design-time packages frequently work by calling runtime packages. To distinguish them from other DLLs, package libraries are stored in files that end with the .bpl (Borland package library) extension.
      Like other runtime libraries, packages contain code that can be shared among applications. For.. more
      You can compile a package from the IDE or from the command line.
      Creating a package involves specifying:
      • A name for the package.
      • A list of other packages to be required by, or linked to, the new package.
      • A list of unit files to be contained by, or bound into, the package when it is compiled. The package is essentially a wrapper for these source-code units . The Contains clause is where you put the source-code units for custom components that you want to compile into a package.
      RAD Studio generates a package source file (.dpk).
      • Understanding the Structure of a.. more
      Refer to Understanding the structure of a package for more information about the steps outlined here.
      A custom package is either a .bpl you code and compile yourself or an existing package from a third-party vendor. To use a custom runtime package with an application, choose ProjectOptions and add the name of the package to the Runtime Packages edit box on the Packages page.
      For example, suppose you have a statistical package called stats.bpl. To use it in an application, the line you enter in the Runtime Packages edit box might look like this:
      Several runtime packages, including rtl and vcl (VCL application) , supply basic language and component support. The vcl (VCL) package contains the most commonly used components; the rtl package includes all the non-component system functions and Windows interface elements. It does not include database or other special components, which are available in separate packages.
      To create a client/server database application that uses packages, you need several runtime packages, including vcl, vcldb, rtl, and dbrtl (VCL) . If you want to use visual components in your application, you also need vclx (VCL) . To use these packages, choose ProjectOptions,.. more
      You deploy packages much like you deploy other applications. The files you distribute with a deployed package may vary. The bpl and any packages or dlls required by the bpl must be distributed.
      Files deployed with a package
      Design-time packages are used to install components on the IDE's Tool palette and to create special property editors for custom components. Which ones are installed depends on which edition of Delphi you are using and whether or not you have customized it. You can view a list of what packages are installed on your system by choosing ComponentInstall Packages...
      The design-time packages work by calling runtime packages, which they reference in their Requires clause. For example, dclstd references vcl. The dclstd itself contains additional functionality that makes many of the standard components available on the Tool palette.. more
      Package source files, like project files, are generated by Delphi from information you supply. Like project files, they can also be edited manually. A package source file should be saved with the .dpk (Delphi package) extension to avoid confusion with other files containing Del source code.
      All components are installed in the IDE as packages. If you've written your own components, create and compile a package that contains them. Your component source code must follow the model described in Overview of component creation.
      Package collections (.dpc files) offer a convenient way to distribute packages to other developers. Each package collection contains one or more packages, including bpls and any additional files you want to distribute with them. When a package collection is selected for IDE installation, its constituent files are automatically extracted from their .pce container; the Installation dialog box offers a choice of installing all packages in the collection or installing packages selectively.
      To create a package, you compile a source file that has a .dpk extension. The base name of the .dpk file becomes the base name of the files generated by the compiler. For example, if you compile a package source file called traypak.dpk, the compiler creates a package called traypak.bpl.
      Create a package when you want to make a custom component that's available through the IDE. Create a standard DLL when you want to build a library that can be called from any application, regardless of the development tool used to build the application.
      The following table lists the file types associated with packages:
      Package files
      The following table lists package-specific compiler directives that you can insert into your source code.
      Package-specific compiler directives
      Runtime packages are deployed with your applications. They provide functionality when a user runs the application.
      To run an application that uses packages, a computer must have both the application's executable file and all the packages (.bpl files) that the application uses. The .bpl files must be on the system path for an application to use them. When you deploy an application, you must make sure that users have correct versions of any required .bpls.
      Packages include the following parts:
      You can dynamically load packages by either:
      • Choosing Project Options dialog box in the IDE; or
      • Using the LoadPackage function.
      When you compile from the command line, you can use the package-specific switches listed in the following table.
      Package-specific command-line compiler switches
      The $WEAKPACKAGEUNIT directive affects the way a .dcu file is stored in a package's .dcp and .bpl files. (For information about files generated by the compiler, see Package files created when compiling.) If {$WEAKPACKAGEUNIT ON} appears in a unit file, the compiler omits the unit from bpls when possible, and creates a non-packaged local copy of the unit when it is required by another application or package. A unit compiled with this directive is said to be weakly packaged.
      For example, suppose you've created a package called pack1 that contains only one unit, unit1. Suppose unit1 does not.. more
      Design-time packages simplify the tasks of distributing and installing custom components. Runtime packages, which are optional, offer several advantages over conventional programming. By compiling reused code into a runtime library, you can share it among applications. For example, all of your applications—including Delphi itself—can access standard components through packages. Since the applications don't have separate copies of the component library bound into their executables, the executables are much smaller, saving both system resources and hard disk storage. Moreover, packages allow faster compilation because only code unique to the application is compiled with each build.