首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为特定的rustup工具链安装Rust目标?

如何为特定的rustup工具链安装Rust目标?
EN

Stack Overflow用户
提问于 2018-11-08 22:46:51
回答 1查看 16.1K关注 0票数 15

我在我的64位Windows机上使用rustccargo编译32位应用程序。这在使用稳定工具链时工作得很好,但是当我尝试使用beta工具链时,它失败了。

beta工具链已与rustup install beta一起成功安装。在项目文件夹中有一个.cargo/config文件,其中包含以下行:

代码语言:javascript
复制
[build]
target = "i686-pc-windows-msvc"

[target.i686-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]

运行cargo +beta build时出现以下错误:

代码语言:javascript
复制
error[E0463]: can't find crate for `core`
  |
  = note: the `i686-pc-windows-msvc` target may not be installed

我试着运行rustup target add i686-pc-windows-msvc来解决这个问题,但是没有帮助;rustup target list甚至显示它为“已安装”。可能这个命令只添加了稳定的目标,而我找不到如何指定beta工具链。

如何为beta工具链添加另一个(非默认)目标?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-08 22:52:22

阅读rustup target add的帮助

代码语言:javascript
复制
$ rustup target add --help
rustup-target-add
Add a target to a Rust toolchain

USAGE:
    rustup target add [OPTIONS] <target>...

FLAGS:
    -h, --help    Prints help information

OPTIONS:
        --toolchain <toolchain>    Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
                                   `rustup help toolchain`

因此,您需要:

代码语言:javascript
复制
rustup target add i686-pc-windows-msvc --toolchain beta

我相信默认情况下它会将目标添加到“当前”工具链中,所以你也可以这样做:

代码语言:javascript
复制
rustup override set beta               # in your project directory
rustup target add i686-pc-windows-msvc #
cargo build                            # no more +beta

rustup target list甚至将其显示为“已安装”

阅读rustup target list的帮助

代码语言:javascript
复制
$ rustup target list --help
rustup-target-list
List installed and available targets

USAGE:
    rustup target list [OPTIONS]

FLAGS:
    -h, --help    Prints help information

OPTIONS:
        --toolchain <toolchain>    Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
                                   `rustup help toolchain`

因此,您需要:

代码语言:javascript
复制
rustup target list --toolchain beta
票数 29
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53210121

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档