Set up Rust on Windows
A quick tip on how to set up a Rust programming environment on Windows.
- Using the VS installer, install following build tools:
- Download Windows x64 installer from cmake website and run the installation with default settings.
- Install Rust using the Rustup installer.
- Install VSCodium with rust-analyzer extension.
-
Create a folder that will store the Rust projects.
-
Open the terminal inside the directory where you intend to create a new Rust project:
- Run the
cargo newcommand to set up the Rust project:
cargo new project_folder_name --name project_app_name
Cargo will then create following directory structure:
- To add project dependencies, add them inside the Cargo.toml file under
[dependencies]:
[dependencies]
example-crate = "0.1.0"
You can chek the latest version of a package on crates.io.
Alternatively, you can add a dependency in the form of a github repository:
[dependencies]
example-crate = { git = "https://github.com/example-user/example-crate.git" }
-
Open
/src/main.rsin VSCodium to edit the Rust file that will be later built into an executable file. -
To build the executable, open the terminal inside the
project_folder_namefolder and run thecargo buildcommand.
The built project’s executable will be located under following path: project_folder_name\target\debug\project_app_name.exe