A basic template to develop a game using Raylib with rust
I started to learn Rust and Raylib together. My main language is Golang, but for game development and other time-critical applications I want to use a faster language. I tried C, C++, Zig, C3, but at the end I decided to go with Rust.
Problem: It took me a while to compile a basic Raylib game with Rust, mainly due to a toolchain problem.
Hence here below my suggestions to configure a working toolchain for Rust and Raylib.
The suggestions below have been tested by myself and work properly.
I am NOT setting up a cross-compiling toolchain but rather a multi-os
toolchain so that I can clone the repo in a computer running either
operating system, and can obtain a workable binary by simply typing
cargo build --release
- Install scoop: I use the scoop package manager for Windows, so that I can have a similar user experience than brew (MacOs) and apt (Linux). Follow the installation commands in their Github repo here
- Install rust:
From a terminal run the command
scoop install rustup
- Setting the default toolchain:
From a terminal run the command
rustup default stable
- Install cmake (needed for Raylib build):
From a terminal run the command
scoop install cmake
- Install llvm (needed to fix a compile error with Raylib):
From a terminal run the command
scoop install llvm
- Install Build Tools for Visual Studio 2022: Click this link to download and install the tools.
- Install git:
From a terminal run the command
scoop install git
- Install VsCode:
From a terminal run the command:
scoop install vscode
- Add the following VsCode extensions:
- rust-analyzer
- vscode-icons
- Even Better TOML
- CodeLLDB
- Install rust:
From a terminal run the command
apt install rustup
- Setting the default toolchain:
From a terminal run the command
rustup default stable
- Install cmake (needed for Raylib build):
From a terminal run the command
apt install cmake
- Install git:
From a terminal run the command
apt install git
- Install VsCode:
- download the .deb package from here
- run the command:
apt install <packagername>.deb
- Add the following VsCode extensions:
- rust-analyzer
- vscode-icons
- Even Better TOML
- CodeLLDB
T.B.D.
Now that you are set, the next step is to clone this repo and test it.
- Open a terminal and go to your projects folder. If you don't have any I suggest that you create one in $HOME/Develop
- Clone this repo:
git clone https://github.com/flevin58/rs_game_template.git
- go inside the repo:
cd rs_game_template
- run the app:
cargo run