Skip to content

Binding C++ with Kotlin Python Swift

Introduction

CppBind is a software development tool that automates language bindings generation between C++ and other languages. It works by annotating C++ code to indicate parts desired to expose to all supported target languages. The current version of the tool supports bindings with Swift, Kotlin, and Python, while support for new languages can be added relatively easily.

Manually developing bindings is complex, time-consuming, and error-prone, especially for large-scale projects requiring frequent changes. To develop manual bindings, one should be knowledgeable in both C++ and the target language to implement types serialization from one language to another, function and method mapping, and more. To overcome these challenges, we introduce CppBind.

CppBind main highlights:

  • Generates binding wrappers for multiple languages (Python, Swift, and Kotlin);
  • Allows using language-agnostic annotations for all supported languages;
  • Supports a rich set of C++ features;
  • Provides the ability to add support for other languages;
  • Can be used to generate bindings for third-party C++ libraries.

Features

CppBind generates bindings for C++ types and entities like classes, methods, global functions, enums, nested structures, templates, etc. The list of the main features of CppBind is following:

Usage

CppBind instructions are controlled using annotations. There are two prominent use cases for annotating C++ source files: either you are the source code owner, or it's from a third-party/standard library. CppBind annotations are specified directly in the source files in the first case. In the second case, separate config files can be used. The second use case works well for binding third-party C++ libraries.

  • To configure a project with self-owned files, you can read our "Hello User" tutorial.
  • To configure a project with third-party/standard library files, you can read our "Array" tutorial.

Above-described usages can also be mixed: annotations for self-owned files are written inside those files, while third-party/standard library files are annotated via separate config files.

Installation

There are some required steps to install and use CppBind. The installation steps are described here.

License

CppBind is provided under the MIT license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

Contributing

If you like CppBind and would like to contribute to this open-source project, please check the Contribution guide.


Last update: December 1, 2022