Warning: THIS WIKI IS DEPRECATED. It is no longer being maintained, and contains outdated and incorrect information. Please refer to the Void Handbook, https://docs.voidlinux.org/, for the official documentation. If you can't find the information you're seeking, please raise an issue at https://github.com/void-linux/void-docs/issues

Rust -

From Void Linux Wiki
Jump to navigation Jump to search

The Rust Programming Language is a multi-paradigm systems programming language that focuses on safe code with high performance. Rust is syntastically similar to C++, but aims to provide memory-safe code whilst still being blazingly fast. As of writing (Sept. 2019) Rust ranks third on The Computer Language Benchmarks Game, just behind C++ and C.


To install Rust it is recommended to install the Rust toolchain manager Rustup by installing the rustup package

# xbps-install -S rustup

The package provides an initialization script that must be run afterwards

$ rustup-init

which guides you through installing a toolchain and other tools for the current user.

Tip: If you plan on developing for your own architecture, you should install a toolchain compatible with your system. For a glibc based version of Void Linux that would be the x86_64-unknown-linux-gnu target triple toolchain that the installer suggests by default. For a musl based version of Void Linux, you should install the x86_64-unknown-linux-musl toolchain.


Creating a new project

Rustup also installs the Rust package manager Cargo alongside the rust toolchain. Cargo makes creating new projects easy by setting up most of the project structure for you. To create a new application simply run

$ cargo new <name_of_project>

If you however wish to create a new library then run

$ cargo new --lib <name_of_library>

Installing another toolchain

Should you wish to develop rust applications for an architecture other than your own, you can install a different toolchain through rustup. To do this run

$ rustup toolchain install <name_of_toolchain>


error: linker `cc` not found

Rust for linux does not check whether a compiler toolchain is present on the system, but assumes that a C linker is present. To fix the issue simply install gcc

# xbps-install -S gcc