$ cbindgen

v0.29.3

A tool for generating C bindings to Rust code.

Downloads: 85.9M
Recent: 11.1M
Versions: 105
Updated: May 28, 2026

Latest Update Summary

Crate

Name: cbindgen New version: 0.29.2 Release date: 2025-05-20T12:13:22Z

Crate readme

Short description cbindgen creates C/C++11 headers for Rust libraries which expose a public C API.

Long description cbindgen generates error-free C/C++11 headers based on Rust libraries with a public C API, allowing both C and C++ headers to be emitted from the same library. It can be used as a simple standalone program or as a library in your build.rs. It provides a configuration file (cbindgen.toml) to set options for generating headers, with the ability to produce headers in both C and C++ formats.

Features • Generates C/C++11 headers from Rust libraries • Supports both C and C++ output from the same library • Simple to use as either a standalone program or as a library • Requires a configuration file (cbindgen.toml)

Code Examples Cargo installation

 cargo install --force cbindgen

Homebrew installation

 brew install cbindgen

Generate header file for C++

 cbindgen --config cbindgen.toml --crate my_rust_library --output my_header.h

Generate header file for C

 cbindgen --config cbindgen.toml --crate my_rust_library --output my_header.h --lang c

Linkshttps://github.com/mozilla/cbindgenhttps://crates.io/crates/cbindgenhttps://docs.rs/cbindgen

https://api.github.com/repos/mozilla/cbindgen/releases/219764621

Release info

Release version: 0.29.0

Release description The 0.29.0 release introduces several significant enhancements and fixes. Notably, it adds support for the no-export annotation on statics and functions, allowing for greater flexibility in how symbols are exported. A new rename rule for generated associated constants has been added to streamline naming conventions. Additionally, the upgrade of the heck package to version 0.5 enhances code generation features. This release also includes support for an optional nullable attribute, enabling more nuanced handling of types. Furthermore, several bug fixes were addressed, including issues with the handling of constexpr literal structs and improved error generation for structures using the keyword as inside arrays. Deprecated spelling issues in documentation were corrected, ensuring clearer communication of deprecated features. Other minor fixes include improvements in generic handling and the renaming of the -Zparse-only flag for better usability.

Code Examples Support no-export annotation for statics and functions

#[no_export]
static MY_STATIC: i32 = 42;

Rename rule for generated associated constant

#[rename]
const MY_CONSTANT: i32 = 100;

Fix deprecated spelling in docs

// Fixed spelling of deprecated_with_note and deprecated_variant_with_note

Patch update: 0.29.2 → 0.29.3

$ DOWNLOADS TREND

60.9M85.9M

$ VERSION HISTORY

v0.29.3May 28, 2026
v0.29.2October 21, 2025
v0.29.0May 20, 2025

$ LINKS

$ INSTALL

cargo add cbindgen

Or add to Cargo.toml: cbindgen = "0.29.3"