There are 2 ways to use rust crates from C. My interest would be using web view from fltk in C.
cbindgen
cargo-c
Are any of these recommended ?
The cargo-c method requires
The TL;DR:
Create a capi.rs with the C-API you want to expose and use #[cfg(cargo_c)]#[cfg(feature="capi")] to hide it when you build a normal rust library.
Make sure you have a lib target and if you are using a workspace the first member is the crate you want to export, that means that you might have to add a "." member at the start of the list.
Since Rust 1.38, also add "staticlib" to the "lib" crate-type. Do not specify the crate-type, cargo-c will add the correct library target by itself.
You may use the feature capi to add C-API-specific optional dependencies.
NOTE: It must be always present in Cargo.toml
Remember to add a cbindgen.toml and fill it with at least the include guard and probably you want to set the language to C (it defaults to C++)
Once you are happy with the result update your documentation to tell the user to install cargo-c and do cargo cinstall --prefix=/usr --destdir=/tmp/some-place or something along those lines.
There are 2 ways to use rust crates from C. My interest would be using web view from fltk in C.
Are any of these recommended ? The cargo-c method requires