Windows11 Rust安装

rust官方地址

Install Rust - Rust Programming Languagehttps://www.rust-lang.org/tools/installhttps://www.rust-lang.org/tools/install

使用pycharm下载安装器

curl https://sh.rustup.rs -sSf | sh

(mlcllm) C:\Users\Administrator\Desktop\mlc-llm-main\mlc-llm>curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure

Welcome to Rust!

The Cargo home directory is located at:

  C:\Users\Administrator\.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:

  C:\Users\Administrator\.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

 安装选项,选择一个(1)默认安装选项

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

输入1, 回车继续执行

屏幕上出现 Rust is installed now. Great!说明安装成功

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
>1

info: profile set to 'default'
info: default host triple is x86_64-pc-windows-msvc
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
821.1 KiB / 821.1 KiB (100 %)  44.8 KiB/s in 21s ETA:  0s
info: latest update on 2025-01-09, rust version 1.84.0 (9fc6b4312 2025-01-07)
info: downloading component 'cargo'
  6.9 MiB /   6.9 MiB (100 %)  35.2 KiB/s in  4m 25s ETA:  0s    
info: downloading component 'clippy'
  2.6 MiB /   2.6 MiB (100 %)  32.0 KiB/s in  1m 28s ETA:  0s
info: downloading component 'rust-docs'
 16.5 MiB /  16.5 MiB (100 %)  44.8 KiB/s in 11m 24s ETA:  0s    
info: downloading component 'rust-std'
 22.2 MiB /  22.2 MiB (100 %)  32.0 KiB/s in 14m 37s ETA:  0s    
info: downloading component 'rustc'
 63.9 MiB /  63.9 MiB (100 %)   1.3 MiB/s in  3m 33s ETA:  0s    
info: downloading component 'rustfmt'
  1.7 MiB /   1.7 MiB (100 %)   1.5 MiB/s in  1s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 16.5 MiB /  16.5 MiB (100 %)   3.0 MiB/s in  3s ETA:  0s
info: installing component 'rust-std'
 22.2 MiB /  22.2 MiB (100 %)  20.2 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 63.9 MiB /  63.9 MiB (100 %)  21.1 MiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc installed - rustc 1.84.0 (9fc6b4312 2025-01-07)


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 (%USERPROFILE%\.cargo\bin).

Press the Enter key to continue.


(mlcllm) C:\Users\Administrator\Desktop\mlc-llm-main\mlc-llm>

如果安装后在终端尝试执行 rustc --version 失败,需要设置环境变量

查看ls -l ~/.cargo/bin 目录

ls -l ~/.cargo/bin

(mlcllm) C:\Users\Administrator\Desktop\mlc-llm-main\mlc-llm>ls -l ~/.cargo/bin
total 178808
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 cargo-clippy.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 cargo-fmt.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 cargo-miri.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 cargo.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 clippy-driver.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rls.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rust-analyzer.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rust-gdb.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rust-gdbgui.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rust-lldb.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rustc.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rustdoc.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rustfmt.exe
-rwxr-xr-x 14 Administrator 197108 13077698 Jan 27 21:04 rustup.exe

(mlcllm) C:\Users\Administrator\Desktop\mlc-llm-main\mlc-llm>

安装完成后,打开一个新的命令提示符或PowerShell窗口,并输入以下命令 

验证rustc Cargo是否正确安装

cargo --version
rustc --version

### 安装 Rust 编程语言Windows 操作系统 #### 下载并安装 Rustup 工具链 为了简化安装过程,在Windows安装Rust变得更为便捷,不再需要繁琐的手动配置环境变量等操作[^1]。通过官方提供的`rustup`工具来完成整个安装流程。 首先访问官方网站或者直接运行命令行指令以获取最新版的`rustup-init.exe`文件: ```powershell iex(new-object net.webclient).DownloadString('https://win.rustup.rs/') ``` 上述PowerShell脚本会自动执行下载以及初始化工作,按照提示完成即可成功部署基础开发套件。 #### 配置 C++ 构建支持 考虑到部分功能可能依赖于C++库的支持,建议提前准备好相应的构建工具集。一种推荐的方式是借助 Visual Studio Installer 来选取必要的组件包,特别是针对桌面开发的工作负载选项中的MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest)[^2]。 这一步骤确保了后续编译过程中不会因为缺少底层链接器或其他辅助程序而遇到障碍。 #### 使用 Cargo 创建新项目 一旦完成了以上准备工作之后,就可以立即体验到由 `cargo` 提供的强大项目管理能力。只需简单输入如下命令就能快速建立一个新的应用程序框架: ```bash cargo new hello_world --bin cd hello_world ``` 此时会在当前目录下生成名为`hello_world`的新文件夹,内部包含了基本的应用模板结构[^4]。 #### 基础命令概览 对于初学者来说,熟悉几个常用的操作可以帮助更快地上手实践: - **格式化代码**: `cargo fmt` - **语法检查**: `cargo check` - **深入分析**: `cargo clippy` - **启动调试版本**: `cargo run` - **发布优化模式下的可执行文件生成**: `cargo build --release` 这些实用的功能都集成到了Cargo这个统一入口之下,极大地方便了开发者日常编码活动。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值