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```shell 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```shell 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```shell 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 57To build the C API of Wasmtime you can run: 58 59```shell 60cargo build --release -p wasmtime-c-api 61``` 62 63This will place the shared library inside of `target/release`. On Linux it will 64be called `libwasmtime.{a,so}`, on macOS it will be called 65`libwasmtime.{a,dylib}`, and on Windows it will be called 66`wasmtime.{lib,dll,dll.lib}`. 67 68## Building Other Wasmtime Crates 69 70You can build any of the Wasmtime crates by appending `-p wasmtime-whatever` to 71the `cargo build` invocation. For example, to build the `wasmtime-environ` crate, 72execute this command: 73 74```shell 75cargo build -p wasmtime-environ 76``` 77 78Alternatively, you can `cd` into the crate's directory, and run `cargo build` 79there, without needing to supply the `-p` flag: 80 81```shell 82cd crates/environ/ 83cargo build 84``` 85