gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 07:56:49 27 4
gpt4 key购买 nike

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

使用 rustup install beta 成功安装了 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

我尝试运行 rustup target add i686-pc-windows-msvc 来解决这个问题,但没有帮助; rustup target list 甚至将其显示为“已安装”。可能这个命令只添加了稳定的目标,我找不到如何指定 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 even displays it as "installed"

阅读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 - 如何为特定的 rustup 工具链安装 Rust 目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53210121/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com