我在64位Windows机器上使用rustccargo来编译32位应用程序.当使用稳定的工具链时,这项工作很好,但当我try 使用beta工具链时,它失败了.

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

[build]
target = "i686-pc-windows-msvc"

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

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

error[E0463]: can't find crate for `core`
  |
  = note: the `i686-pc-windows-msvc` target may not be installed

我曾try 运行rustup target add i686-pc-windows-msvc来解决这个问题,但没有帮助;rustup target list甚至显示为"已安装".可能这个命令只添加了stable的目标,我不知道如何指定beta工具链.

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

推荐答案

阅读rustup target add的帮助:

$ 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`

因此你想要:

rustup target add i686-pc-windows-msvc --toolchain beta

我相信默认情况下,它会将目标添加到"当前"工具链中,因此您还可以执行以下操作:

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的帮助:

$ 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`

因此你想要:

rustup target list --toolchain beta

Rust相关问答推荐

如何在不安全的代码中初始化枚举 struct

如何对字符串引用的引用向量进行排序,而不是对最外层的引用进行排序?

是否有可能同时避免不兼容的不透明类型和代码重复?

支持TLS的模拟HTTP服务器

如何将像烫手山芋一样不透明的值从一个Enum构造函数移动到下一个构造函数?

自定义结果枚举如何支持`?`/`FromResidual`?

在Rust中声明和定义一个 struct 体有什么区别

写入引用会更新基础值,但引用会打印意外的值

对reqwest提供的这种嵌套JSON struct 进行反序列化

在 Rust 中,在第一个空格上分割字符串一次

sha256 摘要仅适用于 &*

为什么Rust中无法推断生命周期?

实现AsyncWrite到hyper Sender时发生生命周期错误

push 方法是否取得所有权?

有没有更好的方法来为拥有 DIsplay 事物集合的 struct 实现 Display?

如何断言代码不会在测试中编译?

`if let` 只是另一种编写其他 `if` 语句的方式吗?

list 中没有指定目标 - 必须存在 src/lib.rs、src/main.rs、[lib] 部分或 [[bin]] 部分

令人困惑的错误消息? (解包运算符)

在 macro_rules 中转义 $ 美元符号