Featured image of post 在windows下安装mingw版本的Rust

在windows下安装mingw版本的Rust

在windows下安装mingw版本的Rust

在windows下安装mingw版本的Rust

事前准备

确保你的电脑安装了MinGW-64,可以使用以下命令:

1
gcc --version

应当有类似如下的结果:

1
2
3
4
gcc (MinGW-W64 x86_64-msvcrt-posix-seh, built by Brecht Sanders) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

下载Rust安装程序

下载GNU版本的Rust安装程序: Windows-GNU版本

运行rustup-init.exe

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Rust Visual C++ prerequisites

Rust requires a linker and Windows API libraries but they don't seem to be
available.

These components can be acquired through a Visual Studio installer.

1) Quick install via the Visual Studio Community installer
   (free for individuals, academic uses, and open source).

2) Manually install the prerequisites
   (for enterprise and advanced users).

3) Don't install the prerequisites
   (if you're targeting the GNU ABI).

>

在这一步选择3,然后Enter

得到如下页面:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  D:\environment\rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  D:\environment\cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  D:\environment\cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>

如果你要把Rust安装在其他位置,一定要根据提示修改系统环境变量RUSTUP_HOMECARGO_HOME

在这一步选择2,然后Enter

有如下内容:

1
2
3
4
I'm going to ask you the value of each of these installation options.
You may simply press the Enter key to leave unchanged.

Default host triple? [x86_64-pc-windows-msvc]

注意!!!

键入如下内容:

1
x86_64-pc-windows-gnu

其他选项不要修改,一路Enter即可。

最后你的页面应该如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Current installation options:


   default host triple: x86_64-pc-windows-gnu
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with selected options (default - just press enter)
2) Customize installation
3) Cancel installation

最后回车一次,等待程序自动运行即可。

Licensed under CC BY-NC-SA 4.0
Progress Infinite!
使用 Hugo 构建
主题 StackJimmy 设计