如何为特定的rustup工具链安装Rust目标? [英] How to install a Rust target for a specific rustup toolchain?
问题描述
我在64位Windows计算机上使用 rustc
和 cargo
来编译32位应用程序。使用稳定的工具链时,此功能可以很好地工作,但是当我尝试使用Beta工具链时,它会失败。
I am using rustc
and cargo
on my 64-bit Windows machine to compile a 32-bit application. This work fine when using the stable toolchain, but when I try to use the beta toolchain it fails.
使用 rustup成功安装了Beta工具链安装Beta
。在项目文件夹中,有一个 .cargo / config
文件,其中包含以下几行:
The beta toolchain was successfully installed with rustup install beta
. In the project folder there is a .cargo/config
file containing the following lines:
[build]
target = "i686-pc-windows-msvc"
[target.i686-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
在运行货物+ beta时构建
会发生以下错误:
When running cargo +beta build
the following error occurs:
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
来解决此问题,但没有帮助; 启动目标列表
甚至将其显示为已安装。可能此命令仅添加了稳定目标,而我找不到如何指定beta工具链。
I have tried running rustup target add i686-pc-windows-msvc
to fix the issue but it didn't help; rustup target list
even displays it as "installed". Possibly this command only adds the target for stable, and I couldn't find out how to specify the beta toolchain.
如何添加另一个(非默认)目标
How can I add another (non-default) target for the beta toolchain?
推荐答案
阅读有关 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
我相信默认情况下会将目标添加到当前工具链中,因此您也可以这样做:
I believe it will add the target to the "current" toolchain by default, so you could also do:
rustup override set beta # in your project directory
rustup target add i686-pc-windows-msvc #
cargo build # no more +beta
rustup目标列表
甚至将其显示为已安装
rustup target list
even displays it as "installed"
阅读有关升级目标列表的帮助:
$ 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
这篇关于如何为特定的rustup工具链安装Rust目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!