37 stable releases (13 major)

31.0.0 Mar 20, 2025
30.0.2 Feb 25, 2025
29.0.1 Jan 21, 2025
28.0.1 Jan 14, 2025
18.0.3 Mar 12, 2024

#428 in WebAssembly

Download history 3286/week @ 2024-12-14 2231/week @ 2024-12-21 2908/week @ 2024-12-28 5000/week @ 2025-01-04 4569/week @ 2025-01-11 3573/week @ 2025-01-18 3619/week @ 2025-01-25 4187/week @ 2025-02-01 5469/week @ 2025-02-08 6103/week @ 2025-02-15 5775/week @ 2025-02-22 5103/week @ 2025-03-01 4727/week @ 2025-03-08 4946/week @ 2025-03-15 4674/week @ 2025-03-22 3313/week @ 2025-03-29

18,451 downloads per month
Used in 4 crates (2 directly)

Apache-2.0 WITH LLVM-exception

3.5MB
54K SLoC

Wasmtime's C API

API Documentation

The API documentation for the Wasmtime C library is hosted here..

Using in a C Project

Using a Pre-Built Static or Dynamic Library

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.

Building Wasmtime's C API from Source

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.

Using in a Rust Project

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.

  1. Add a dependency on the 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" }
  1. In your 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");
}

Dependencies

~18–33MB
~590K SLoC