delphi64-bitvclbpl

Make a VCL package 64-bit compatible


I noticed that in a 64 bit application, the VCL Design components I have written are grayed-out in the component pallette:

VCL pallette

Other third party VCL components work in both 32 and 64 bit.

My BPL can compile in 32-bit and 64-bit mode. There is no code that requires 32 bit only. What can I do to unlock the components to 64 bit applications?

The BPL source code of the VCL component is:

package ......;

{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$ENDIF IMPLICITBUILDING}
{$DESCRIPTION '......'}
{$IMPLICITBUILD OFF}

requires
  rtl,
  vcl,
  VclSmp,
  vclx,
  adortl,
  dbrtl,
  vclactnband,
  xmlrtl,
  vcldb,
  Jcl,
  vclie;

contains
  HsGauge in 'HsGauge.pas',
  .......

end.

I noticed that I cannot install the component when it is compiled in 64 bit (I'm not sure if that is the reason):

32 bit:

32 bit

64 bit:

64 bit


Solution

  • IDE is a win32 program so it can load only win32 dlls and win32 bpls, so you can’t install win64 bpl. By default – all must work correctly and we develop a lot of components, so you broke something by your code. In the modern version of Delphi there is a special attribute for the class that specifies the target platform for your component - “ComponentPlatformsAttribute”. So, if you write something like:

    [ComponentPlatformsAttribute(pidWin32 or pidWin64)]
    TMyButton = class(TButton)
    End;
    

    This component will be valid for Win32 and Win64 platforms, but not valid (gray) for Android, IOS etc.. Try to find a solution there. Read more https://docwiki.embarcadero.com/Libraries/Alexandria/en/System.Classes.ComponentPlatformsAttribute

    P.S. If it does not help – try to create a simple bpl with a simple sample component and try to use it in win64. If it works – compare settings of this BPL with your not workable BPL. Then move differences one by one into sample BPL until that will stop working. There how you find out what’s wrong.