代码之家  ›  专栏  ›  技术社区  ›  blerontin

如何为特定的生锈工具链安装生锈目标?

  •  2
  • blerontin  · 技术社区  · 7 年前

    rustc 和 cargo 在我的64位Windows机器上编译32位应用程序。当使用稳定的工具链时,这个工作很好,但是当我尝试使用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
    

    我试过跑步 rustup target add i686-pc-windows-msvc 解决这个问题,但没有帮助; rustup target list

    1 回复  |  直到 7 年前
        1
  •  27
  •   Shepmaster Tim Diekmann    7 年前

    阅读帮助以获取 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 --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