diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index daaed04081..9e19695ba4 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -23,6 +23,8 @@ - [Annotating types with `#[must-use]`](./must-use-types.md) - [Field visibility](./visibility.md) - [Code formatting](./code-formatting.md) + - [Libloading](./libloading.md) + - [Generating Bindings to C++](./cpp.md) - [Generating Bindings to Objective-c](./objc.md) - [Using Unions](./using-unions.md) diff --git a/book/src/libloading.md b/book/src/libloading.md new file mode 100644 index 0000000000..2c6865ecae --- /dev/null +++ b/book/src/libloading.md @@ -0,0 +1,8 @@ +It is also possible to generate bindings for dynamically loading a shared library via the [`libloading`](https://docs.rs/libloading/latest/libloading/) crate. +To generate libloading bindings for a library `shared_lib` we can either use the function `dynamic_library_name` function in `build.rs` or the CLI argument `--dynamic-loading` when using the bindgen CLI. + +Here is an example using the bindgen CLI: +``` +bindgen wrapper.h --dynamic-loading MySharedLib --output bindings.rs +``` +Bindgen will generate a `libloading` struct matching the name of the `--dynamic-loading` argument. So in the case of the example above the generated struct will have the name `MySharedLib`.