1. Rust目录
📒 D:/Install/Dev/Rust
📂 Mingw64
📂 CargoHome
📂 RustSource
📂 RustupHome
📂 RustAnalyzerWinMsvc
📂 RustSpace
📂 rust-module
2. 安装Mingw64
|
gcc --version && gcc -v
gcc (x86_64-win32-seh-rev0, Built by MinGW-Builds project) 14.2.0
Copyright (C) 2024 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.
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=D:/Install/Dev/Rust/Mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/14.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-14.2.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/buildroot/x86_64-1420-win32-seh-ucrt-rt_v12-rev0/mingw64 --enable-host-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libstdcxx-threads=yes --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libssp --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-seh-rev0, Built by MinGW-Builds project' --with-bugurl=https://github.com/niXman/mingw-builds LD_FOR_TARGET=/c/buildroot/x86_64-1420-win32-seh-ucrt-rt_v12-rev0/mingw64/bin/ld.exe --with-boot-ldflags='-pipe -fno-ident -L/c/buildroot/x86_64-1420-win32-seh-ucrt-rt_v12-rev0/mingw64/opt/lib -L/c/buildroot/prerequisites/x86_64-zlib-static/lib -L/c/buildroot/prerequisites/x86_64-w64-mingw32-static/lib -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc'
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 14.2.0 (x86_64-win32-seh-rev0, Built by MinGW-Builds project)
3. 环境变量
|
Entry | Location |
---|---|
CARGO_HOME |
D:\Install\Dev\Rust\CargoHome |
RUSTUP_HOME |
D:\Install\Dev\Rust\RustupHome |
RUST_SRC_PATH |
D:\Install\Dev\Rust\RustSource |
RUSTUP_DIST_SERVER |
|
RUSTUP_UPDATE_ROOT |
vim C:/Users/Administrator/.cargo/config
[source.crates-io]
replace-with = 'mirror'
[source.mirror]
registry = "https://mirror.nju.edu.cn/git/crates.io-index.git"
4. 安装步骤
|
-
双击运行rustup-init.exe
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) Don’t Install Prerequisite,Targeting GNU ABI
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:\Install\Dev\Rust\RustupHome
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
D:\Install\Dev\Rust\CargoHome
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:\Install\Dev\Rust\CargoHome\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
-
2) Customize Installation
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]
-
x86_64-pc-windows-gnu
Default toolchain? (stable/beta/nightly/none) [stable]
-
stable
Profile (which tools and data to install)?
(minimal/default/complete) [default]
-
default
Modify PATH variable? (Y/n)
-
Y
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)
2) Customize installation
3) Cancel installation
>
-
1) Proceed with selected options (default);
info: profile set to 'default'
info: setting default host triple to x86_64-pc-windows-gnu
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04)
info: downloading component 'cargo'
10.2 MiB / 10.2 MiB (100 %) 4.5 MiB/s in 2s ETA: 0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
15.9 MiB / 15.9 MiB (100 %) 2.3 MiB/s in 6s ETA: 0s
info: downloading component 'rust-mingw'
4.7 MiB / 4.7 MiB (100 %) 347.7 KiB/s in 7s ETA: 0s
info: downloading component 'rust-std'
22.8 MiB / 22.8 MiB (100 %) 1.0 MiB/s in 30s ETA: 0s
info: downloading component 'rustc'
75.8 MiB / 75.8 MiB (100 %) 5.5 MiB/s in 38s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
15.9 MiB / 15.9 MiB (100 %) 3.1 MiB/s in 3s ETA: 0s
info: installing component 'rust-mingw'
info: installing component 'rust-std'
22.8 MiB / 22.8 MiB (100 %) 18.7 MiB/s in 1s ETA: 0s
info: installing component 'rustc'
75.8 MiB / 75.8 MiB (100 %) 20.1 MiB/s in 3s ETA: 0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'
stable-x86_64-pc-windows-gnu installed - rustc 1.81.0 (eeb90cda1 2024-09-04)
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload its PATH environment variable to include
Cargo's bin directory (D:\Install\Dev\Rust\CargoHome\bin).
Press the Enter key to continue.
5. 验证安装
rustc -V && echo. && rustup show && echo. && rustup -V && echo. && cargo -V
# rustc -V
rustc 1.81.0 (eeb90cda1 2024-09-04)
# rustup show
Default host: x86_64-pc-windows-gnu
rustup home: D:\Install\Dev\Rust\RustupHome
stable-x86_64-pc-windows-gnu (default)
rustc 1.81.0 (eeb90cda1 2024-09-04)
# rustup -V
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.81.0 (eeb90cda1 2024-09-04)`
# cargo -V
warning: `C:\Users\Administrator\.cargo\config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
cargo 1.81.0 (2dbb1af80 2024-08-20)