1# Building 2 3This section describes everything required to build and run Wasmtime. 4 5## Prerequisites 6 7Before we can actually build Wasmtime, we'll need to make sure these things are 8installed first. 9 10### Git Submodules 11 12The Wasmtime repository contains a number of git submodules. To build Wasmtime 13and most other crates in the repository, you have to ensure that those are 14initialized with this command: 15 16```console 17git submodule update --init 18``` 19 20### The Rust Toolchain 21 22[Install the Rust toolchain here.](https://www.rust-lang.org/tools/install) This 23includes `rustup`, `cargo`, `rustc`, etc... 24 25### `libclang` (optional) 26 27The `wasmtime-fuzzing` crate transitively depends on `bindgen`, which requires 28that your system has a `libclang` installed. Therefore, if you want to hack on 29Wasmtime's fuzzing infrastructure, you'll need `libclang`. [Details on how to 30get `libclang` and make it available for `bindgen` are 31here.](https://rust-lang.github.io/rust-bindgen/requirements.html#clang) 32 33## Building the `wasmtime` CLI 34 35To make an unoptimized, debug build of the `wasmtime` CLI tool, go to the root 36of the repository and run this command: 37 38```console 39cargo build 40``` 41 42The built executable will be located at `target/debug/wasmtime`. 43 44To make an optimized build, run this command in the root of the repository: 45 46```console 47cargo build --release 48``` 49 50The built executable will be located at `target/release/wasmtime`. 51 52You can also build and run a local `wasmtime` CLI by replacing `cargo build` 53with `cargo run`. 54 55## Building the Wasmtime C API 56 57See 58[`crates/c-api/README.md`](https://github.com/bytecodealliance/wasmtime/blob/main/crates/c-api/README.md) 59for details. 60 61## Building Other Wasmtime Crates 62 63You can build any of the Wasmtime crates by appending `-p wasmtime-whatever` to 64the `cargo build` invocation. For example, to build the `wasmtime-environ` crate, 65execute this command: 66 67```console 68cargo build -p wasmtime-environ 69``` 70 71Alternatively, you can `cd` into the crate's directory, and run `cargo build` 72there, without needing to supply the `-p` flag: 73 74```console 75cd crates/environ/ 76cargo build 77``` 78