Command Line Usage
Install thebindgen
executable withcargo
:
$ cargo install bindgen-cli
Thebindgen
executable is installed to~/.cargo/bin
. You have to add thatdirectory to your$PATH
to usebindgen
.
bindgen
takes the path to an input C or C++ header file, and optionally anoutput file path for the generated bindings. If the output file path is notsupplied, the bindings are printed tostdout
.
If we wanted to generated Rust FFI bindings from a C header namedinput.h
andput them in thebindings.rs
file, we would invokebindgen
like this:
$ bindgen input.h -o bindings.rs
For more details, pass the--help
flag:
$ bindgen --help