• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Library Usage with `build.rs`
2
3�� This is the recommended way to use `bindgen`. ��
4
5Often times C and C++ headers will have platform- and architecture-specific
6`#ifdef`s that affect the shape of the Rust FFI bindings we need to create to
7interface Rust code with the outside world. By using `bindgen` as a library
8inside your `build.rs`, you can generate bindings for the current target
9on-the-fly. Otherwise, you would need to generate and maintain
10`x86_64-unknown-linux-gnu-bindings.rs`, `x86_64-apple-darwin-bindings.rs`,
11etc... separate bindings files for each of your supported targets, which can be
12a huge pain. The downside is that everyone building your crate also needs
13`libclang` available to run `bindgen`.
14
15## Library API Documentation
16
17[�� There is complete API reference documentation on docs.rs ��](https://docs.rs/bindgen)
18
19## Tutorial
20
21The next section contains a detailed, step-by-step tutorial for using `bindgen`
22as a library inside `build.rs`.
23