1

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

Daniel Marschall
  • 3,739
  • 2
  • 28
  • 67
  • 1
    You can only install 32 bit packages into the IDE as the IDE is 32 bit. If your 64 bit package has the same name as the installed 32 bit package and the 64 bit package can be found in your 64 bit paths it will be available to a 64 bit project. Note that you will have to set your output package directory to somewhere appropriate (not the same directory for 32bit and 64bit) and the 64 bit package must be findable on the 64 bit paths. – Rob Lambden Feb 06 '23 at 22:44
  • 2
    Move your component registration into a separate 32bit design-time package, which you can then install into the IDE. You can leave the component itself in a runtime package that can be compiled for 32bit and 64bit, and which the design-time package requires. – Remy Lebeau Feb 06 '23 at 23:46
  • @RobLambden This is pretty simplistic. So many ways to find DLLs. Shared system wide path is how we did it in the last millennium. Private assemblies are how you escape from DLL hell. Then again the question asked isn't really about that. – David Heffernan Feb 06 '23 at 23:57
  • Sorry for my ignorance... I don't understand what I need to do. The package mode is "run-time and design-time". I have now set the Win64 BPL output path to C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\Win64 and the Win32 BPL output path to C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl . I compiled both and installed the 32-bit variant into the IDE. In the project settings of the 64-bit application, I have added the ...\Bpl\Win64 directory to the Unit Search Path. The VCL controls are still grayed out in the palette. – Daniel Marschall Feb 07 '23 at 11:32
  • @DavidHeffernan - I was referring to the fact that the IDE looks for packages in places defined by the configured paths. I was unaware that Delphi could build assemblies if you could share a link to some documentation I would be very grateful. – Rob Lambden Feb 08 '23 at 16:05
  • The ide is 32 bit so it doesn't look for 64 bit packages. So 64 bit packages are runtime only. They are just DLLs. They are located in the same way as all DLLs. Private assemblies are a well documented feature of windows and not Delphi. – David Heffernan Feb 08 '23 at 18:33
  • @DanielMarschall you should separate design time and runtime packages. Why are you even struggling with packages anyway. Much easier to build a single monolithic executable. – David Heffernan Feb 08 '23 at 18:35

2 Answers2

2

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.

Softacom
  • 613
  • 2
  • 6
  • Thank you very much for the help! I have now applied `ComponentPlatformsAttribute` to all components, and it works! (Tested with Delphi 10.4). The default behavior for Delphi 10.4 (without `ComponentPlatformsAttribute`) seems to be 32-bit only; I have created a new BPL with a simple component `TTestGauge = class(TGauge) end` and `RegisterComponents('Test', [THsTestGauge]);`, and it is grayed out in Win64. That's odd. – Daniel Marschall Feb 07 '23 at 18:30
  • @Softacom - thanks for sharing this - but my 64 bit components have always worked fine without using this attribute. – Rob Lambden Feb 08 '23 at 16:04
0

Delphi IDE is a 32 bit application and need 32 bit packages to be able to use components at design time.

Your 64 bit application need a 64 bit run-time package, that's why Delphi can build 64 bit packages.

If you don't use run-time package in your application then there is no need to create one.

fpiette
  • 11,983
  • 1
  • 24
  • 46