OS Manuals

/usr/bin/cbindgen

Tool to generate C bindings from Rust code

From cbindgen 0.29.4-r9 (os), captured 2026-11-05 by running cbindgen --help (exit 0). permalink

Generate C bindings for a Rust library

Usage: cbindgen [OPTIONS] [INPUT]

Arguments:
  [INPUT]  A crate directory or source file to generate bindings for. In general this is the folder where the Cargo.toml file of source Rust library resides.

Options:
  -v...                           Enable verbose logging
      --verify                    Generate bindings and compare it to the existing bindings file and error if they are different
  -c, --config <PATH>             Specify path to a `cbindgen.toml` config to use
  -l, --lang <LANGUAGE>           Specify the language to output bindings in [possible values: c++, C++, c, C, cython, Cython]
      --package-version           Include the package version in the header comment
      --cpp-compat                Whether to add C++ compatibility to generated C bindings
      --only-target-dependencies  Only fetch dependencies needed by the target platform. The target platform defaults to the host platform; set TARGET to override.
  -s, --style <STYLE>             Specify the declaration style to use for bindings [possible values: Both, both, Tag, tag, Type, type]
  -d, --parse-dependencies        Whether to parse dependencies when generating bindings
      --clean                     Whether to use a new temporary directory for expanding macros. Affects performance, but might be required in certain build processes.
      --crate <CRATE_NAME>        If generating bindings for a crate, the specific crate to generate bindings for
  -o, --output <PATH>             The file to output the bindings to
      --lockfile <PATH>           Specify the path to the Cargo.lock file explicitly. If this is not specified, the Cargo.lock file is searched for in the same folder as the Cargo.toml file. This option is useful for projects that use workspaces.
      --metadata <PATH>           Specify the path to the output of a `cargo metadata` command that allows to get dependency information. This is useful because cargo metadata may be the longest part of cbindgen runtime, and you may want to share it across cbindgen invocations. By default cbindgen will run `cargo metadata --all-features --format-version 1 --manifest-path <path/to/crate/Cargo.toml>
      --profile <PROFILE>         Specify the profile to use when expanding macros. Has no effect otherwise. [possible values: Debug, debug, Release, release]
  -q, --quiet                     Report errors only (overrides verbosity options).
      --depfile <PATH>            Generate a depfile at the given Path listing the source files cbindgen traversed when generating the bindings. Useful when integrating cbindgen into 3rd party build-systems. This option is ignored if `--out` is missing.
      --symfile <PATH>            Generate a list of symbols at the given Path. This list can be given to a linker in order to compile an application that exposes dynamic symbols. Useful when creating a plugin system with a C interface.
  -h, --help                      Print help
  -V, --version                   Print version
Options (20)
OptionDescriptionSource
-vEnable verbose logginghelp
--verifyGenerate bindings and compare it to the existing bindings file and error if they are differenthelp
-c, --config PATHSpecify path to a `cbindgen.toml` config to usehelp
-l, --lang LANGUAGESpecify the language to output bindings in [possible values: c++, C++, c, C, cython, Cython]help
--package-versionInclude the package version in the header commenthelp
--cpp-compatWhether to add C++ compatibility to generated C bindingshelp
--only-target-dependenciesOnly fetch dependencies needed by the target platform.help
-s, --style STYLESpecify the declaration style to use for bindings [possible values: Both, both, Tag, tag, Type, type]help
-d, --parse-dependenciesWhether to parse dependencies when generating bindingshelp
--cleanWhether to use a new temporary directory for expanding macros.help
--crate CRATE_NAMEIf generating bindings for a crate, the specific crate to generate bindings forhelp
-o, --output PATHThe file to output the bindings tohelp
--lockfile PATHSpecify the path to the Cargo.lock file explicitly.help
--metadata PATHSpecify the path to the output of a `cargo metadata` command that allows to get dependency information.help
--profile PROFILESpecify the profile to use when expanding macros.help
-q, --quietReport errors only (overrides verbosity options).help
--depfile PATHGenerate a depfile at the given Path listing the source files cbindgen traversed when generating the bindings.help
--symfile PATHGenerate a list of symbols at the given Path.help
-h, --helpPrint helphelp
-V, --versionPrint versionhelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.