Set up Rust on Windows

A quick tip on how to set up a Rust programming environment on Windows.

  1. Download Visual Studio 2022 Community Edition installer.
  1. Using the VS installer, install following build tools:
  1. Download Windows x64 installer from cmake website and run the installation with default settings.
  1. Install Rust using the Rustup installer.
  1. Install VSCodium with rust-analyzer extension.
  1. Create a folder that will store the Rust projects.

  2. Open the terminal inside the directory where you intend to create a new Rust project:

  1. Run the cargo new command to set up the Rust project:
 cargo new project_folder_name --name project_app_name

Cargo will then create following directory structure:

  1. 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" }
  1. Open /src/main.rs in VSCodium to edit the Rust file that will be later built into an executable file.

  2. To build the executable, open the terminal inside the project_folder_name folder and run the cargo build command.

The built project’s executable will be located under following path: project_folder_name\target\debug\project_app_name.exe