Crates.io | wasmtime-c-api-impl |
lib.rs | wasmtime-c-api-impl |
version | 25.0.3 |
source | src |
created_at | 2024-02-20 22:09:46.078766 |
updated_at | 2024-11-05 19:27:09.862298 |
description | C API to expose the Wasmtime runtime |
homepage | |
repository | https://github.com/bytecodealliance/wasmtime |
max_upload_size | |
id | 1147222 |
size | 554,426 |
The API documentation for the Wasmtime C library is hosted here..
Each release on Wasmtime's GitHub Releases page has pre-built binaries for both static and dynamic libraries for a variety of architectures and operating systems attached, as well as header files you can include.
To use Wasmtime from a C or C++ project, you must have CMake and a Rust toolchain installed.
From the root of the Wasmtime repository, run the following commands:
$ cmake -S crates/c-api -B target/c-api --install-prefix "$(pwd)/artifacts"
$ cmake --build target/c-api
$ cmake --install target/c-api
These commands will produce the following files:
artifacts/lib/libwasmtime.{a,lib}
: Static Wasmtime library. Exact extension
depends on your operating system.
artifacts/lib/libwasmtime.{so,dylib,dll}
: Dynamic Wasmtime library. Exact
extension depends on your operating system.
artifacts/include/**.h
: Header files for working with Wasmtime.
If you have a Rust crate that contains bindings to a C or C++ library that uses Wasmtime, you can link the Wasmtime C API using Cargo.
wasmtime-c-api-impl
crate to your Cargo.toml
. Note that package name differs from the library name.[dependencies]
wasmtime-c-api = { version = "16.0.0", package = "wasmtime-c-api-impl" }
build.rs
file, when compiling your C/C++ source code, add the C wasmtime-c-api
headers to the include path:fn main() {
let mut cfg = cc::Build::new();
// Add to the include path the wasmtime headers and the standard
// Wasm C API headers.
cfg
.include(std::env::var("DEP_WASMTIME_C_API_INCLUDE").unwrap());
// Compile your C code.
cfg
.file("src/your_c_code.c")
.compile("your_library");
}