# Cross compilation

You can cross compile your Rust code using the target specifier. For example:

```bash
cargo build --target x86_64-unknown-linux-gnu --release
```

You can list all targets using `rustup target list` and add the targets you need. But often you need an environment with the correct tooling. This is made easier using the **cross** ([Github](https://github.com/cross-rs/cross)) tool.

### Install cross

You can simply use cargo to install cross:

```bash
cargo install cross --git https://github.com/cross-rs/cross
```

Cross requires either **docker or podman** on your machine, because it uses docker images to provide the necessary tooling.

It automatically chooses the engine, but you can also set it using the environment variable <span class="s1">`CROSS_CONTAINER_ENGINE`.</span>

### <span class="s1">Build using cross</span>

<span class="s1">You can now build using cross by replacing the "cargo build" with "cross build":</span>

```bash
# cross build --target <your target> <additional parameters>
cross build --target x86_64-unknown-linux-gnu --release

# Or with a different container engine
CROSS_CONTAINER_ENGINE=podman cross build --target x86_64-unknown-linux-gnu --release
```