Wednesday, October 8, 2008

Delphi Packages not appearing in C++ Builder personality

One of the new features in CodeGear RAD Studio 2007 (actually Borland Developer Studio which is the 2006 version of RAD Studio) is the ability to get the Delphi compiler / linker to generate all the files required by C++ Builder (.hpp, .obj, .lib etc.) for a Delphi package, without having to create the equivalent C++ Builder package.

Unfortunately, there's one ugly bug that has plagued this feature - you may find that the components in the package that you've installed does not come up in the designer's Tool Palette. This bug was first reported by yours truly against BDS 2006 and it appears that it hasn't been and won't be fixed even for RAD Studio 2009. That's more than 3 years since I've reported it in QC! Wow!

If you have left all settings to the default when you create a package in Delphi (which you most likely will), you will find that the components you've registered in the package won't appear in a C++ Builder project. That is simply because you have not specifically told the linker to "Generate all C++Builder files". So you would go back to the Delphi package and select that option in the Linker output and recompile / reinstall. This time, however, you would expect the installed components to appear in the Tool Palette when you try to use it in C++ Builder... Surprise surprise, it's not there!

It's as though once the IDE has decided that it is a Delphi-only package, it will remain a Delphi-only package forever. Note that if you uninstall and recreate and then reinstall the entire package, it will still be invisible to C++ Builder - that is, until you've renamed the package. That's because the IDE remembers the package name!

The other cleaner workaround would be to go to your registry via Regedit.exe and remove all the following entries to your package (say, MyPackage.bpl).

Key:
HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Known Packages\
Entry:
Look for the entry with [path]\MyPackage.bpl and remove it

Key:
HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Package Cache\
Look for the key called MyPackage.bpl and remove the entire sub-key


Key:
HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Palette\Cache\
Look for the key called MyPackage.bpl and remove the entire sub-key


Remember to first shut down CodeGear RAD Studio before changing the registry keys. Once you have removed the entries, restart RAD Studio and this time, remember to select "Generate all C++Builder files" for all build configurations (e.g. Debug and Release) before you install the Delphi package.

And in the future, keep in mind to always set the linker to "Generate all C++Builder files" or set that as your default for all build configurations.

ps. Yup, they haven't rebranded it to CodeGear in the registry - it's still Borland as we know it! :)

7 comments:

Remy Lebeau said...

The "feature" of the compiler to produce C++ support files (hpp, obj, lib, etc) is not new to BDS. The command-line Pascal compiler that has shipped with every version of C++Builder since the beginning has always had that feature. The only thing that is new in BDS is that the feature has finally been added to the IDE's GUI as user-configurable options, that's all.

Jon said...

The problem is still present in RAD Studio 2009 - and the same fix still applies, only now they have renamed it from Borland to CodeGear in the registry.

SoCo said...

I stumbled across this post because I had the same problem in RAD Studio 2010. Unfortunately I installed a 3rd party component, kbmMW 3.40.1, and part of it, the kbmMemTable part only shows in the Delphi tool palette. Oddly the kbmMW part that I don't need does show in in both Delphi and CB. This component was automatically installed with an installer, which is likely to blame. Time to try to install the package from source with the option you mentioned.

Anonymous said...

Yep, same problem today with RAD Studio 2010. I changed the linker options which was not succcessful. Then I renamed the package. That was as mentioned the solution.
Thanks for that hint! Wasted a lot of time during the last years...

SlavaC said...

I have this problem in RAD 2007 with dbExpress. In Delphi personality I see all the installed components, but in C++ I see only TSimpleDataSet. Any ideas how to solve this?

Anonymous said...

I can confirm that this bug still exists in XE4.

Anonymous said...

This Bug persists in XE5. Incredible