A collection of sample code snippets demonstrating how to create bindings for various programming languages based on C++
- 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)
- Download and install CMake from the official website or trough a package manager
- Install vcpkg from the official website or trough a package manager
- Check dependencies required for your Linux, MacOS or Windows system in pr.yml workflow
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
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
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>
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
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
Run (does not consider a shared library from compiled C++ source code):
cd bindings/rust
cargo run