Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

book: Add information about libloading #3087

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions book/src/libloading.md
Original file line number Diff line number Diff line change
@@ -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`.
Loading