Cross-compilation Tools
Recipe | Crates | Categories |
---|---|---|
Cross-compile for Multiple Target OSes and Architectures | ||
Cross-compile with cargo |
Build Systems | Use cargo, xtask (for managing complex builds) |
Target Specification | Handled by cargo through target triples |
C/C++ Dependencies | Often a source of complexity; cc ⮳ crate can help |
Platform-Specific Code | Use conditional compilation attributes like cfg to manage platform-specific code |
Foreign Function Interface (FFI) | Use std::ffi (for interacting with C code, which might require cross-compilation) |
Cross-compile with cargo
Cross-compile for Multiple Target OSes and Architectures
Cross-Compilation Tools include cross
⮳, a popular tool that uses Docker to simplify cross-compilation.
cross
⮳ simplify cross-compilation. It builds your Rust project for different target operating systems and architectures from a single development environment. It requires rustup
⮳ and Docker
⮳ or Podman
⮳.
cargo install cross --git https://github.com/cross-rs/cross
# Optionally, if you have `cargo-binstall`, you can install the pre-built binary
cargo binstall cross
cross
⮳ has the exact same CLI as cargo
⮳ but relies on docker
⮳ or podman
⮳.
cross build --target aarch64-unknown-linux-gnu
cross test --target mips64-unknown-linux-gnuabi64
cross run --target aarch64-unknown-linux-gnu
Related Topics
- Autocfg.
- Build Time Tooling.
- Development Tools: Build Utils.
- Hardware Support.