Build Delphi Packages for C++
Go Up to Clang-enhanced C++ Compilers
The C++ Win64 Modern platform uses COFF
format object files and libraries, and when building Delphi packages for C++Builder, you need to ensure that you generate files this toolchain can consume. This requires building twice: once for ELF
, and once for COFF
.
Objects and static libraries (.a
, .lib
) and package import libraries (.bpi
) are in either COFF
format for the Modern toolchain, or ELF
format for the legacy toolchain. These are incompatible, and ELF objects/libraries cannot be linked to apps built with the new toolchain; therefore, each must be distributed in separate folders. The $(Platform)
environment variable should expand to 'Win64x' when using the Modern toolchain, allowing you to use this environment variable when distributing your package to customer machines, i.e., you can place files appropriately in folders named 'win64' and 'win64x' in the Library path if you use this environment variable.
To create COFF
files using the IDE, follow these steps:
- Add the Windows 64-bit Modern Platform to your Delphi package project.
- Set it to generate C++ files by setting the 'C/C++ Output file generation' to 'Generate all C++Builder files'
- Build the Delphi package.
On the command line:
- Whether you use the
-jphne
command when you have misc.pas
files or-JL
for a package, use-jf:coffi
to generateCOFF
-format C++ files.
Unlike other files, the dynamic package itself (.bpl
) and the headers (.hpp
) compiled by Delphi are compatible with both formats simultaneously. Only objects and static libraries or the package import library are format-dependent.
However, a package (.bpl
) built with the legacy Win64 compiler cannot be used with an app built with the Modern Win64 compiler, and vice versa. Delphi-origin packages are compatible with both, but C++-origin packages must only be used by the same toolchain that created them.
For more details, refer to the table below.
Win64/ELF | Win64 (Modern)/COFF | Description | |
---|---|---|---|
Package Build Command | dcc64 -JL package.dpk
|
dcc64 -JL -jf:coffi package.dpk
|
|
Identical Files Shared between Platforms | .hpp and .bpl
|
.hpp and .bpl
|
The .hpp and .bpl produced here are interchangeable. These can be in a folder that is shared between the two platforms that target Windows 64-bit. |
Platform Specific Files |
.a and .bpi
|
.lib and .bpi
|
* Use the .a and .lib files when linking statically. * Use the .bpi when linking dynamically. These files must be kept separate for the two platforms. |