How is your experience with using C++ libraries in Rust?

This page summarizes the projects mentioned and recommended in the original post on /r/rust

Our great sponsors
  • JetBrains Dev Survey - What’s up with the C++ ecosystem in 2023?
  • Onboard AI - ChatGPT with full context of any GitHub repo.
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern API for authentication & user identity.
  • rust-bindgen

    Automatically generates Rust FFI bindings to C (and some C++) libraries.

    I tried using a C++ library using bindgen, and while it worked the generated Rust bindings where HUGE and included a ton of things from the C++ stdlib (isn't header files just a wonderful concept...). So instead I wrapped the C++ code in a small C library with a minimal API (basically just depending on stdint.h). That produced minimal Rust bindings and integrates with Rust very well (except for C strings which are a PITA), I think it was worth the extra hours spent.

  • cxx

    Safe interop between Rust and C++

    A while ago I started integrating a C++ project using cxx. However, cxx was not straightforward to set up at the time, and the project had a mostly "C with classes" code style. So eventually I used bindgen, by creating my own C API. Nowadays, to work with a modern C++ API, I'd definitely give cxx another try.

  • JetBrains Dev Survey

    What’s up with the C++ ecosystem in 2023? JetBrains Developer Ecosystem Survey 2023 has given us many interesting insights. The Embedded (37%) and Games (39%) industries are already working with C++20, developers are incorporating static analysis in their CI, and ChatGPT usage among coders is flourishing. Read on for more!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts