You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Alex Crichton ca5f1bb627
Tidy up some headers related to shared memory (#8366)
7 months ago
..
artifact Enable the gc feature by default in the c-api (#8356) 7 months ago
include Tidy up some headers related to shared memory (#8366) 7 months ago
src Tidy up some headers related to shared memory (#8366) 7 months ago
.gitignore Add support for documenting the C API (#1928) 4 years ago
CMakeLists.txt Remove wasm-c-api submodule (#8170) 8 months ago
Cargo.toml Enable the gc feature by default in the c-api (#8356) 7 months ago
LICENSE Move the C API to a separate crate (#818) 5 years ago
README.md Add wasmtime-c-api-impl to the list of crates to publish (#7837) 9 months ago
build.rs Remove wasm-c-api submodule (#8170) 8 months ago
doxygen.conf Remove wasm-c-api submodule (#8170) 8 months ago

README.md

Wasmtime's C API

For more information you can find the documentation for this library online.

Using in a C Project

To use Wasmtime from a C or C++ project, you can use Cargo to build the Wasmtime C bindings. From the root of the Wasmtime repository, run the following command:

cargo build --release wasmtime-c-api

This will create static and dynamic libraries called libwasmtime in the target/release directory.

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());
        .include(std::env::var("DEP_WASMTIME_C_API_WASM_INCLUDE").unwrap());

    // Compile your C code.
    cfg
        .file("src/your_c_code.c")
        .compile("your_library");
}