Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++How-To'sIDEModernizationNewsRAD StudioWindows

Practical Info: Packages in C++Builder 12.2

We’ve released the new Windows 64-bit Modern C++ toolchain over time: a preview in C++Builder 12.0 through to fully complete in 12.2 (dynamic package linking, CMake support, parallel building by default, etc.) In 12.2, it is a full replacement for the old Win64 toolchain.

But we’ve seen a few customers say, ‘Looks exciting, and I want to use it, but where are packages?’

They’re here.

The source of that might be that we released in stages, a ‘ship in public’ approach with as open communication as we could. And one of those releases did not include dynamic linking to packages. But it’s there now.

And we wrote a bunch of extra documentation, too.

Creating Packages in C++Builder 12.2

12.2’s Win64 Modern toolchain is a full replacement for the old toolchain. That means:

  1. You can create a package through File > New > Package – C++Builder, or on the Welcome screen:
    Screenshot of the Welcome page's 'New Package - C++Builder' item
  2. If you have a package, just turn on the platform in the Projects view
    [image]
    Shows a package in the Projects view with the Windows 64 bit Modern platform active

It’s really as simple as that.

Making Delphi Components work in C++Builder 12.2

Ok, that was too easy. Most components are written in Delphi, though, and put into Delphi-source packages. If you are a package author, and this section is mostly for third party component vendors, you need to enable the new Win64 platform.

How? Steps are in Build Delphi Packages for C++. (Basically, add the platform and rebuild; you need to pay attention to the output folder since while the headers are the same, the package import library and package static library are COFF format. If you have a build script instead of building in-IDE, there are new compiler flags. See the doc page for info.)

Documentation

Packages are a feature that are part of our multi-language support, where we support direct ABI-level interop with Delphi, and are effectively a Delphi feature transplanted to C++. They’re very useful for things like components or controls, and are a DLL plus metadata/extras. (For components, this means supporting registration of the component/control types, for example.)

But because they are not a ‘native’ C++ feature, over the years we’ve had many questions about various aspects of using them. So, matching the brand new package implementation in 12.2, we wrote new docs. This includes concrete recommendations for how to use them, suggested do-s and don’t-s.

Some specific questions we’ve seen are: how do I know when a type is exported from a package, or imported into a package? (What does that even mean?) What is unit initialization? What should I do to use packages in the way they’re meant to be used?

These should all be answered here:

  • Packages for the New C++ Toolchain – general page for the topic. Sub-pages include:
    • Package Import and Export – this is one of the most important pages to read. It explains how and when types are imported into a packages, or exported from a package. Most confusion around using packages comes from not understanding how this works, or what to do, and we have recommendations for best practices on this page.
    • Unit Initialization and Finalization – this explains how units are initialised and finalised as a package is loaded or unloaded, and even what this means at all
    • Using the Weak Packaging directive – weakly packaged units inside packages were already documented, but it ties in to the concepts in the above pages and we have written a more thorough explanation.

Remember, the new Windows 64-bit Modern toolchain in C++Builder 12.2 is the one we recommend you use. Not only does it have a revised and more robust implementation of packages, but we have significant documentation too.

Happy coding!

 

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

David is an Australian developer, currently living in far-north Europe. He is the senior product manager for C++ at Idera, looking after C++Builder and Visual Assist.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES