#
Resolving Delphi 64-bit Package Installation Issues
The transition to 64-bit computing offers significant advantages, particularly the ability to address vast amounts of memory, crucial for modern, data-intensive applications. Delphi, since version XE2, has provided developers with the capability to compile native 64-bit applications for Windows. However, this powerful feature introduces a unique set of challenges, especially concerning the installation and management of components and libraries, commonly known as packages (.bpl
files). Many developers encounter frustrating hurdles when trying to integrate 64-bit packages into their workflow.
This guide provides a comprehensive exploration of these challenges and offers detailed, step-by-step solutions. The core issue stems from a fundamental architectural characteristic: the Delphi Integrated Development Environment (IDE) itself remains a 32-bit application, even in the latest versions. This discrepancy between the 32-bit IDE and the 64-bit target platform is the primary source of confusion and errors related to package management.
Understanding this core constraint is the first step towards a smooth development experience. We will delve into why the 32-bit IDE necessitates 32-bit design-time packages, how to correctly configure project settings for both 32-bit and 64-bit targets, the role of runtime packages, and essential testing strategies to ensure your application functions flawlessly on both architectures.
#
The Root Cause: Why a 32-bit IDE Needs 32-bit Design-Time Packages
The Delphi IDE is the central hub for visual design, code editing, debugging, and project management. When you place a component onto a form in the Form Designer, interact with its properties in the Object Inspector, or use custom component editors, the IDE needs to load and execute the code contained within the component's design-time package.
Because the bds.exe
(the Delphi IDE executable) is a 32-bit process, it operates within the 32-bit memory space and adheres to the rules of 32-bit execution. It simply cannot load or execute 64-bit code directly. Attempting to load a 64-bit DLL (or in Delphi's case, a 64-bit .bpl
package) into a 32-bit process will result in an immediate failure, typically manifesting as errors like "Can't load package %s" or cryptic operating system errors.
Therefore, for the IDE to function correctly at design time – allowing you to visually manipulate components, configure properties, and utilize design-time features – it must load the 32-bit (x86) version of your component packages. This is non-negotiable due to the IDE's architecture.
This requirement often leads to the misconception that only 32-bit packages are needed, or confusion about why separate 64-bit packages exist if the IDE can't load them. The key is differentiating between design time (within the 32-bit IDE) and compile/run time (where your application can be either 32-bit or 64-bit).
#
Step 1: Installing the 32-bit (x86) Design-Time Package
Based on the explanation above, the first mandatory step is always to install the 32-bit version of your component package into the Delphi IDE.
- Obtain the Packages: Ensure you have both the 32-bit (often named with suffixes like
_x86
,_Win32
, or simply without a platform specifier in older versions) and 64-bit (_x64
,_Win64
) compiled package files (.bpl
and.dcp
). These are typically generated when you build your component library project for both Win32 and Win64 platforms. If using third-party components, the vendor should supply both versions. - Open the IDE: Launch the Delphi IDE.
- Install Package: Navigate to
Component > Install Packages...
. - Add Package: Click the "Add..." button.
- Locate 32-bit BPL: Browse to the directory containing your 32-bit compiled package file (
.bpl
). Select the 32-bit.bpl
file and click "Open". - Confirm: The package should now appear in the "Design packages" list, usually enabled by default. Click "OK".
The IDE will load the 32-bit package. If successful, your components should appear on the Tool Palette, and you can use them in the Form Designer. If the IDE fails to load the package, double-check that you selected the correct 32-bit .bpl
file and that any dependencies required by that package are also available and correctly installed.
Never attempt to install the 64-bit .bpl
file using the Component > Install Packages...
menu. It will invariably fail because the 32-bit IDE cannot load it.
#
Step 2: Configuring Project Library Paths for Both Platforms
While the IDE uses the 32-bit package at design time, the Delphi compiler needs to know where to find the appropriate files (.dcu
, .dcp
, .obj
) for the specific platform you are targeting during compilation (either 32-bit or 64-bit). This is configured within the project options, specifically the library path settings. These settings are platform-specific.
- Open Project Options: Go to
Project > Options...
. - Select Target Platform: Crucially, you must configure paths separately for each platform. Use the "Target Platform" dropdown menu at the top of the Project Options dialog. Start by selecting "32-bit Windows".
- Navigate to Library Path: In the options tree on the left, select
Delphi Compiler > Library
. - Add 32-bit Path: In the "Library path" field, click the ellipsis (...) button. Add the directory containing your compiled 32-bit units (
.dcu
files) and the 32-bit package's.dcp
file for the components you installed. Ensure this path points specifically to the 32-bit output directory of your component library. - Switch to 64-bit Platform: Now, change the "Target Platform" dropdown to "64-bit Windows". Notice that the "Library path" might change or be empty.
- Add 64-bit Path: Repeat step 4, but this time, add the directory containing your compiled 64-bit units (
.dcu
files) and the 64-bit package's.dcp
file. This path must be different from the 32-bit path and point to the 64-bit output directory. - Verify Other Paths (Optional but Recommended): While the Library path is essential for finding
.dcu
and.dcp
files, also check theBrowsing path
(used by code insight) and ensure theDCP output directory
is appropriately set if you are building packages yourself. Configure these for both 32-bit and 64-bit platforms as well. - Save Changes: Click "OK" to save the project options.
Common Mistake: Forgetting to switch the "Target Platform" dropdown before setting the path for that platform. Setting the 64-bit path while "32-bit Windows" is selected (or vice-versa) is a frequent source of compilation errors.
By correctly configuring these platform-specific library paths, you tell the compiler exactly where to find the necessary .dcu
and .dcp
files for the architecture you are currently building.
#
Step 3: Managing Runtime Packages
Beyond telling the compiler where to find units during compilation, you also need to decide how your final executable will link against the component libraries. This is controlled by the "Runtime Packages" settings.
You have two main choices:
- Static Linking: If you leave the "Link with runtime packages" option unchecked (or clear the list of packages), the compiler will link the necessary code and resources from your components directly into your final
.exe
file. This results in a larger executable but avoids the need to distribute separate.bpl
files with your application. - Dynamic Linking (Runtime Packages): If you check "Link with runtime packages" and list the required packages, the compiler will not embed the component code into your
.exe
. Instead, your application will load the necessary.bpl
files at runtime. This leads to smaller executables but requires you to deploy the corresponding 32-bit or 64-bit.bpl
files alongside your application.
Configuration:
- Open Project Options: Go to
Project > Options...
. - Select Target Platform: Choose either "32-bit Windows" or "64-bit Windows".
- Navigate to Packages: Select
Packages > Runtime Packages
in the options tree. - Enable/Disable: Check or uncheck the "Link with runtime packages" option based on your desired linking method.
- Specify Packages: If using runtime packages, ensure the list below contains the correct base name(s) of the packages your application uses (e.g.,
MyComponentPackage
). Do not include the platform suffix or file extension here. Delphi automatically appends the correct platform identifiers and loads the appropriate_x86.bpl
or_x64.bpl
(or equivalent naming based on Delphi version/settings) at runtime. - Repeat for Other Platform: Switch the "Target Platform" and configure the runtime package settings identically for the other platform. Usually, the decision to use or not use runtime packages is consistent across both platforms, but the list of packages might differ if you use platform-specific libraries.
- Save Changes: Click "OK".
Deployment Consideration: If you choose to use runtime packages, remember that you must distribute the correct version (32-bit or 64-bit) of those .bpl
files with your application. The 32-bit executable needs the 32-bit .bpl
s, and the 64-bit executable needs the 64-bit .bpl
s. Place them either in the same directory as the .exe
or in a location accessible via the system's PATH environment variable.
#
Step 4: Thorough Testing and Verification
Configuration alone isn't enough. Rigorous testing is essential to confirm that everything works as expected on both platforms.
- Compile for Both Platforms: Build your project explicitly for both "32-bit Windows" and "64-bit Windows" target platforms. Address any compiler errors that arise. Errors during compilation often point to incorrectly configured library paths (Step 2).
- Run 32-bit Version: Execute the compiled 32-bit application. Test all functionality that relies on the components in question. Look for:
- Correct visual appearance and behavior of components.
- Absence of exceptions during component creation or method calls.
- If using runtime packages, ensure the application starts without "Package XYZ not found" errors.
- Run 64-bit Version: Execute the compiled 64-bit application. Perform the exact same tests as for the 32-bit version. Pay close attention to:
- Any differences in behavior compared to the 32-bit version.
- Runtime errors such as Access Violations, which could indicate underlying 64-bit compatibility issues in the component code itself or how your application uses it (e.g., incorrect pointer arithmetic, integer size assumptions).
- Again, check for missing package errors if using runtime packages, ensuring the 64-bit
.bpl
s are accessible.
- Test Edge Cases: Include tests that push the boundaries, especially concerning memory usage if that's a reason for moving to 64-bit. Load large datasets, perform complex operations involving the components.
Any discrepancies or errors encountered during runtime on one platform but not the other strongly suggest a problem either in the package configuration (Steps 2 or 3) or potential 64-bit compatibility issues within the component or application code itself.
#
Troubleshooting Common Problems
- "Package XYZ.bpl can't be installed because it is not a design time package.": You likely tried to install the package via
Component > Install Packages
but it lacks the necessary design-time registrations or flags. Ensure the package project is correctly configured to be a design-time or design-time & runtime package. - "Can't load package XYZ.bpl. %1 is not a valid Windows application." / "The specified module could not be found.": You are almost certainly trying to install a 64-bit BPL into the 32-bit IDE via
Component > Install Packages
. Only install the 32-bit BPL this way. The "module not found" variant can also occur if the package has dependencies that aren't installed or found. - [Compiler Error] F1026 File not found: 'ComponentUnit.dcu': This occurs during compilation (not design time). It means the compiler cannot find the required
.dcu
file for the currently selected target platform. Double-check yourProject Options > Delphi Compiler > Library > Library path
settings for the specific platform you are compiling (Step 2). Ensure the path points to the correct directory (32-bit or 64-bit) containing the.dcu
files. - [Linker Error] E2202 Required package 'XYZ' not found: Similar to F1026, but occurs during the linking phase. It often means the
.dcp
file for the package cannot be found. Verify the Library Path (Step 2) includes the directory containing the correct platform's.dcp
file. Also, ensure the package name is correctly listed inProject Options > Packages > Runtime Packages
if you are linking dynamically (Step 3). - Runtime Error: "Package XYZ not found": Your application was compiled to use runtime packages, but the required
.bpl
file (matching the application's bitness) cannot be found when the application starts. Ensure the correct 32-bit or 64-bit.bpl
files are deployed alongside your.exe
(Step 3). - Runtime Access Violations (AVs) only in 64-bit: This usually indicates 64-bit compatibility issues in the code (either your application or the component). Common culprits include:
- Pointer arithmetic assuming
SizeOf(Pointer)=4
. - Incorrect use of
Integer
vsNativeInt
/NativeUInt
for handles or pointer-sized values. - Direct calls to Windows API functions using incorrect data types for 64-bit.
- Data structure alignment issues. Debugging the 64-bit application is necessary to pinpoint the cause.
- Pointer arithmetic assuming
#
Handling Third-Party Components
The principles outlined above apply equally to third-party components. Reputable vendors will provide:
- Clear instructions for installation.
- Separate 32-bit and 64-bit compiled
.bpl
,.dcp
, and.dcu
files. - An installer that often handles placing files in appropriate locations and potentially installs the 32-bit design-time package into the IDE automatically.
If an installer is provided, use it first. However, always verify the project options (Library Paths, Runtime Packages) afterwards, as installers may not always perfectly configure paths for every possible project setup or Delphi version. If you only receive raw library files, follow Steps 1-3 manually, ensuring you correctly identify and path the 32-bit and 64-bit versions supplied by the vendor. If you encounter issues, consult the vendor's documentation or contact their support.
#
Conclusion
Successfully managing Delphi packages for both 32-bit and 64-bit development hinges on understanding the 32-bit nature of the IDE and meticulously configuring project options for each target platform separately. Always install the 32-bit package for design time, and then carefully set the platform-specific Library Paths and Runtime Package settings to ensure the compiler and your final application can find and use the correct files for the target architecture.
While it adds complexity compared to purely 32-bit development, this structured approach allows you to leverage the power of 64-bit compilation while maintaining a fully functional design-time experience within the familiar Delphi IDE. Consistent testing across both platforms is the final, crucial step to guarantee robust and reliable applications.
Need further assistance? Please contact support for help with specific scenarios or component issues.