LLMpediaThe first transparent, open encyclopedia generated by LLMs

cbindgen

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: Duktape Hop 4
Expansion Funnel Raw 77 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted77
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
cbindgen
Namecbindgen
AuthorUnknown
DeveloperOpen source community
Released2016
Programming languageRust
Operating systemCross-platform
LicenseMIT/Apache-2.0

cbindgen

cbindgen is a software tool for generating C header files from Rust code. It automates creation of C-compatible headers for projects that interoperate between Rust and C, facilitating integration with libraries, applications, and systems that rely on C interfaces. The tool is commonly used in projects involving the Rust compiler, LLVM, and a variety of systems libraries.

Overview

cbindgen originated in the context of systems programming and interlanguage tooling among projects like Rust (programming language), LLVM, and Mozilla Research. It addresses the need to expose Rust data types and function signatures to ecosystems that include GCC, Clang, Microsoft Visual Studio, and other toolchains. The tool is relevant to repositories hosted on platforms such as GitHub and GitLab, and is often integrated into continuous integration pipelines alongside services like Travis CI, GitHub Actions, and CircleCI.

Features

cbindgen supports generation of headers for public Rust APIs that use #[repr(C)] types, enums, and extern "C" functions, enabling interoperability with projects like glibc, musl, and platform-specific SDKs such as the Windows SDK and the Android NDK. It can output C, C++, and Objective-C compatible declarations useful for bindings in projects referencing frameworks like Qt (software), Cocoa, and Win32 API. The tool understands Rust visibility and attributes, integrating with build systems including Cargo (package manager), CMake, and Bazel (software). Advanced features enable customization of type mappings for interactions with projects using LLVM libc++, libstdc++, and third-party libraries such as OpenSSL and SQLite.

Usage

Typical usage of cbindgen involves invoking it in a repository that uses Cargo (package manager) to emit a header file during build or release steps. Developers integrate the tool into workflows alongside linters and formatters like rustfmt, Clippy, Prettier, and static analyzers such as Coverity and SonarQube. Common invocation patterns include running cbindgen from command-line environments on Linux, macOS, and Windows, or invoking it in containerized environments managed by Docker or orchestration platforms such as Kubernetes. cbindgen is often employed in projects that interoperate with embedded toolchains provided by vendors like ARM, NXP, and Intel.

Configuration and API

cbindgen is configured using a TOML file that coexists with Cargo.toml and can be customized for target triples such as x86-64, ARMv7, and aarch64. The configuration supports mappings to C types used by POSIX platforms and platform-specific ABIs like the System V ABI and Microsoft x64 calling convention. Its API is exposed as a CLI and as a Rust crate for programmatic invocation, enabling integration with build tools like Make (software), Ninja (build system), and Meson build system. The configuration also supports header guards and module inclusion patterns similar to those used by legacy projects like SQLite and curl.

Examples

Example projects using cbindgen include bindings for multimedia libraries such as FFmpeg, cryptography libraries like libsodium, and GUI toolkits such as GTK and SDL (library). In cross-language examples, cbindgen is used alongside language bindings for Python (programming language), Ruby (programming language), and Java via the Java Native Interface and for interoperability with Swift (programming language) and Objective-C. Common example workflows appear in repositories maintained by organizations including Mozilla Foundation, Dropbox, Microsoft, Amazon (company), and Google.

Development and Maintenance

cbindgen development occurs in open-source repositories where contributors collaborate using issue trackers, pull requests, and code review workflows popularized by GitHub. Maintenance typically involves coordinating with the broader Rust (programming language) community, ensuring compatibility with new compiler versions and with upstream projects like LLVM and GCC. Continuous integration testing often runs on cloud CI providers such as GitHub Actions, Azure Pipelines, and GitLab CI/CD to validate cross-platform behavior on Linux, Windows, and macOS. Community governance and contribution guidance often reference practices used by organizations like the Rust Foundation and large open-source projects such as Linux kernel and Kubernetes.

License and Distribution

cbindgen is distributed under permissive licenses similar to those used by many Rust ecosystem projects, allowing redistribution and integration into both open source and proprietary projects. Distribution channels include source archives on crates.io and binary artifacts attached to releases on GitHub Releases and package registries used by organizations like Homebrew, Chocolatey, and APT (Advanced Package Tool). Users rely on package managers and CI/CD systems to automate installation and distribution in production environments managed by providers such as AWS, Google Cloud Platform, and Microsoft Azure.

Category:Software