Rust
Rust is a systems programming language that runs blazingly fast, prevents nearly all segfaults, and guarantees thread and memory safety.
Contents
Installation
To install the latest stable version of Rust, install the rust package.
If you would like to build the stable or Beta from source, visit Rust Downloads. You may also obtain rust-nightly-binAUR via the AUR for the latest development snapshot (provides Cargo).
Test your installation
Check that Rust is installed correctly by building a simple program, as follows:
~/hello.rs
fn main() { println!("Hello, World!"); }
You can compile it with rustc
, then run it:
$ rustc hello.rs && ./hello
Hello, World!
Cross Compiling
Windows
In this section, $ARCH
is the target architecture (either x86_64
or i686
).
- Install mingw-w64-gcc and wine
- Add a binfmt definition for windows executables either manually or by installing binfmt-wineAUR.
- Install a copy of rust's standard library for windows in your rustlib directory (
/usr/local/lib/rustlib
if you're using rust-nightly-binAUR and/usr/lib/rustlib
if you're using the official rust package). The easiest way to do this is to download the rust installer for windows for your target architecture, install it under wine (wine start my-rust-installer.msi
) and copy$INSTALL_DIR/bin/rustlib/$ARCH-pc-windows-gnu
into your rustlib directory. - Finally, tell cargo where to find the MinGW-w64 gcc/ar by adding the following to your cargo config:
~/.cargo/config
[target.$ARCH-pc-windows-gnu] linker = "/usr/bin/$ARCH-w64-mingw32-gcc" ar = "/usr/$ARCH-w64-mingw32/bin/ar"
Finally, you can cross compile for windows by passing the --target $ARCH-pc-windows-gnu
to cargo:
$ # Build $ cargo build --release --target "$ARCH-pc-windows-gnu" $ # Run unit tests under wine $ cargo test --target "$ARCH-pc-windows-gnu"
Cargo
Cargo, Rust's package manager, is available as cargo-binAUR.
Cargo is a tool that allows Rust projects to declare their various dependencies, and ensure that you'll always get a repeatable build.
Usage
To create a new project using Cargo:
$ cargo new hello_world --bin