Rust language from entry to pit - (2) Rust builds a development environment on windows


insert image description here

0 import

Start building a Rust environment suitable for running on windows.

There are many programming languages ​​supported by Rust: see the official website for details

insert image description here


1. Build a Visual Studio Code development environment

This article is mainly to build a development environment under windows

First, you need to install the latest versions of the Rust build tools and Visual Studio Code.

Rust's compilation tool depends on the C language compilation tool, which means that at least one C language compilation environment already exists 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 Windows operating system, you need to install Visual Studio 2013 or above (requires C/C++ support) to use MSVC or install MinGW + GCC compilation environment (Cygwin has not been tested).

1.1. Install Rust compilation tools

The Rust build tools recommend using the Rustup installation just downloaded from the link above. The downloaded Rustup is an executable program rustup-init.exe on Windows,
now execute the rustup-init file:
insert image description here
If you have installed MSVC (recommended), the installation process will be very simple, enter 1 and press Enter to enter directly second step.
If you are installing MinGW, then you need to enter 2 (custom installation), and then the system will ask you Default host triple? Please change the "msvc" of the default host triple in the above figure to "gnu" and enter the installer:
insert image description here
All other attributes are default.
After setting all the options, you will return to the installation wizard interface (the first picture), which is just to enter 1 and press Enter.
insert image description here
This step completes the installation of Rust, which can be tested by the following command:

rustc -V        # 注意的大写的 V
//或者
cargo -V

1.2, VS Code installation

Many previous articles have explained this, but you need to pay attention to the problem of download source when installing VScode. If you don’t choose domestic, it will basically not work. This point should be noted. After downloading, we mainly need to download two plug-ins: 1.
rust- analyzer
2、Native Debug

1. First create a project folder and open the folder in VScode;
2. First build a terminal
3. Use the cargo command to execute the creation of the project: cargo new test
4. Switch to the project: cd ./test to write the program
5. Compile and run: cargo build cargo run

**Cargo is a build system and package manager for Rust. **Follow-up will be specially introduced


2. The official website is online

If you don't want to bother to install, just to test the code, you can recommend online debugging: Portal

insert image description here
After clicking in, there is a relatively simple environment
insert image description here
. The code on the left and the result after Run on the right are still easy to use.


3. Summary

Compared with the development environment and code writing, it is still unknown whether it is necessary to install the corresponding environment in the subsequent operating environment. Whether this refers to the Go language is still unknown, and we will explore it slowly later.


4. Quote

1. Rust Tutorial


Guess you like

Origin blog.csdn.net/ljsant/article/details/131220877