Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

A collection of sample code snippets demonstrating how to create bindings for various programming languages based on C++

License

Notifications You must be signed in to change notification settings

MGTheTrain/cpp-sample-bindings

Repository files navigation

cpp-sample-bindings

Table of Contents

Summary

A collection of sample code snippets demonstrating how to create bindings for various programming languages based on C++

Reference

Features

  • Modular code base
  • CI workflows for QA
  • Sample Python wrappers refering to C++ compiled source code resulting in shared libraries
  • Sample Rust wrappers utilizing cxx and refering to C++ source code
  • Sample Go wrappers refering to C++ compiled source code resulting in shared libraries
  • Sample C# wrappers refering to C++ compiled source code resulting in shared libraries
  • C++ audio module (Optional, Experimental)
  • C++ video module (Optional, Experimental)

Getting started

Prerequisite

CMake

Unix

In order to compile the source code and link the binaries run in a Unix terminal:

cd devops/scripts/bash/
./compile_source_code.sh -CMakeToolchainFile <path to the vcpkg.cmake file>

In order to additionaly start the test executables in a Unix terminal:

cd devops/scripts/bash/
./compile_source_code.sh -CMakeToolchainFile <path to the vcpkg.cmake file> -RunTests

Windows

In order to compile the source code and link the binaries run in a PowerShell terminal:

cd devops\scripts\ps1
.\compile_source_code.ps1 -CMakeToolchainFile <path to the vcpkg.cmake file>

In order to additionaly start the test executables in a PowerShell terminal:

cd devops\scripts\ps1
.\compile_source_code.ps1 -CMakeToolchainFile <path to the vcpkg.cmake file> -RunTests

Bindings

Python

After C++ source code compilation resuting in a shared library, run:

cd bindings/python
python main.py --path <path to libcore_wrapper.so> --wrapper <core, audio> --audio_file_path <path to audio file if wrapper option 'audio' is selected>

C#

After C++ source code compilation resuting in a shared library, run:

cd bindings/csharp
dotnet build
# Copy on unix systems the libcore_wrapper.so to the `bindings/c#/Mgtt.CoreWrapper/bin/Debug/net8.0` folder
dotnet run

Go

After C++ source code compilation resuting in a shared library, run:

cd bindings/go
# Copy in the devcontainer the libcore_wrapper.so to this folder
export LD_LIBRARY_PATH=/workspaces/cpp-sample-bindings/bindings/go/libcore_wrapper.so:$LD_LIBRARY_PATH
go run main.go

Rust

Run (does not consider a shared library from compiled C++ source code):

cd bindings/rust
cargo run

About

A collection of sample code snippets demonstrating how to create bindings for various programming languages based on C++

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published