English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Rust Environment Setup

Rust supports many integrated development environments (IDE) or development-specific text editors.

The tools supported by the official website are as follows (https://www.rust-lang.org/zh-CN/tools):

This tutorial will use Visual Studio Code as our development environment (Eclipse has a version specifically for Rust development, which is also a good choice for beginners).

Note: It is difficult to debug after installing the plugin for IntelliJ IDEA, so it is recommended that developers who are accustomed to using IDEA use CLion, but CLion is not free.

Set up Visual Studio Code Development Environment

Firstly, you need to install the latest version of the Rust compilation tool and Visual Studio Code.

Rust compilation tool:https://www.rust-lang.org/zh-CN/tools/install

Visual Studio Code:https://code.visualstudio.com/Download

The Rust compilation tool depends on the C language compilation tool, which means that there is at least one C language compilation environment on your computer. If you are using a Linux system, you usually already have GCC or clang. If you are using macOS, you need to install Xcode. If you are using the Windows operating system, you need to install Visual Studio 2013 or above environment (requires C/C++ supported) to use MSVC or install MinGW + GCC compilation environment (Cygwin has not been tested).

Install Rust compilation tool

The Rust compilation tool is recommended to use the Rustup installation downloaded from the link above. The downloaded Rustup is an executable program rustup-init.exe. (On other platforms, it should be rustup-init.sh ).

Now execute rustup-init file:

The picture above shows a command line installation wizard.

If you have already installed MSVC (recommended), the installation process will be very simple, input 1 and press Enter to directly enter the second step.

If you are installing MinGW, you need to input 2 (custom installation), then the system will ask you Default host triple? Please refer to the picture above default host triple Change the "msvc" to "gnu" and then input the installation program:


other properties are all default.

After setting all options, you will return to the installation wizard interface (the first picture), which is where we input 1 Press Enter.

You have completed the installation of Rust, and you can test it with the following command:

rustc -V # Note the uppercase V


If the above two commands can output the version number you installed, it means the installation was successful.

Set up Visual Studio Code Development Environment

After downloading the VSCode installation package, start the installation wizard to install (this step will not be elaborated here).

After installing Visual Studio Code (hereinafter referred to as VSCode), run VSCode.

Find "Extensions" in the left sidebar, search for "Chinese", and install the Simplified Chinese extension to change the interface to Chinese. (This step can be skipped if you prefer an English interface or your computer does not support Chinese characters).

Install the two extensions rls and Native Debug in the same way.



Restart VSCode, and the Rust development environment is set up.

Now create a new folder, such as w3codebox-greeting.

Open the new folder in VSCode:

After opening the folder, select "Terminal" from the menu bar-"New Terminal", which will open a new terminal:

Type the following command in the terminal:

cargo new greeting

A Rust project directory named greeting will be built in the current directory.


Now type the following three commands in the terminal:

cd ./greeting 
cargo build 
cargo run

When the system creates a project, it will generate a Hello, world source program main.rs, which will be compiled and run:

Congratulations, you have successfully built a Rust command-line program!

For questions about debugging programs in VSCode, see Cargo Tutorial.