window安装rust

window安装rust

Rust for Windows

Rust 支持主流的操作系统,Linux,Mac和 Windows。

Rust在Windows上的安装和你在windows上安装其它软件一样。

1、下载安装包:

下载地址

Rust提供了多个版本和多个平台的安装包,下载对应的即可,此处我们以1.6.0的稳定版为例。

2、安装:

双击下载到的安装包,如下图所示:
在这里插入图片描述

默认,rust将安装到所有用户下,选择“Advanced”,可以指定安装用户和安装路径。然后点击”install”等待几分钟即可(中间可能会有安全提示,点击允许即可,如果你装了360之类的,需要小心360阻止写入注册表)。

3.验证安装:

安装完成后,运行windows命令行,然后输入:

rustc --version

在这里插入图片描述

看到 以 rustc 1.6.0 开头,说明你安装成功了。

注意

中国科学技术大学镜像源包含 rust-static,梯子暂时出问题的同学可以尝试从这里下载编译器;除此之外。还有 Crates 源,详见这里的说明

版本管理工具–rustup

rustup 是rust官方的版本管理工具。应当作为安装 Rust 的首选。

项目主页是: https://github.com/rust-lang-nursery/rustup.rs

rustup在 Windows 上的工作方式与在 Unix 上的工作方式相同,但对于 Windows 上的 Rust 开发人员有一些特殊的考虑。如Rust 下载页面所述,Windows 上使用了两种ABI : Visual Studio使用的本机 (MSVC) ABI和GCC 工具链使用的 GNU ABI 。您需要哪个版本的 Rust 在很大程度上取决于您想要与之互操作的 C/C++ 库:对于与 Visual Studio 生成的软件的互操作,请使用 Rust 的 MSVC 构建;要与使用MinGW/MSYS2 工具链构建的 GNU 软件互操作,请使用 GNU 构建。

以 MSVC ABI 为目标时,Rust 还需要安装 Visual Studio 2013(或更高版本)或 Visual C++ Build Tools 2019,以便 rustc使用其链接器和库。Visual C++ 构建工具需要 Visual Studio 许可证(社区版、专业版或企业版)。

对于 Visual Studio,请务必选中“C++ 工具”和“Windows 10 SDK”选项。基本使用 GNU 构建不需要额外的软件安装。

默认情况下,在 Windows 上将 Rust 配置为以 MSVC ABI 为目标,rustup即目标三元组i686-pc-windows-msvc, 取决于主机 Windows 操作系统的 CPU 架构。除非通过工具链规范另有说明,否则选择安装的工具 将被编译为在该目标三重主机上运行,并且默认以该三重主机为目标。x86_64-pc-windows-msvc``aarch64-pc-windows-msvc``rustup

rustup set default-host您可以在安装过程中或在安装过程中更改此行为。

例如,要显式选择 32 位 MSVC 主机:

$ rustup set default-host i686-pc-windows-msvc

或者选择 64 位 GNU 工具链:

$ rustup set default-host x86_64-pc-windows-gnu

由于 MSVC ABI 提供与其他 Windows 软件的最佳互操作性,因此建议用于大多数用途。GNU 工具链始终可用,即使您默认不使用它。只需安装它rustup toolchain install

$ rustup toolchain install stable-gnu

不过,您不需要切换工具链来支持所有 Windows 目标;单个工具链支持所有四个 x86 Windows 目标:

$ rustup target add x86_64-pc-windows-msvc
$ rustup target add x86_64-pc-windows-gnu
$ rustup target add i686-pc-windows-msvc
$ rustup target add i686-pc-windows-gnu

有关使用相同编译器指定不同目标的更多详细信息,请参阅交叉编译一章。

安装tustup步骤

选择自定义安装

If you will be targeting the GNU ABI or otherwise know what you are
doing then it is fine to continue installation without the build
tools, but otherwise, install the C++ build tools before proceeding.

Continue? (y/N) y


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:

  C:\Users\smile\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  C:\Users\smile\.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\smile\.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 installation (default)
2) Customize installation
3) Cancel installation
>2

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]


Default toolchain? (stable/beta/nightly/none) [stable]
nightly

Profile (which tools and data to install)? (minimal/default/complete) [default]
minimal

Modify PATH variable? (Y/n)
y


Current installation options:


   default host triple: x86_64-pc-windows-msvc
     default toolchain: nightly
               profile: minimal
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mrrunsen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值