入坑 Rust-lang 程序 error: could not exec the linker `link.exe`:

安装 Rust-lang

下载地址

找到 Windows (MSVC ABI †) (.msi) 下载 一步步安装

Hello word

创建 main.rs

fn main() {
    println!("Hello, world!");
}

终端运行

F:coding\rust-lang>rustc main.rs
error: could not exec the linker `link.exe`: 系统找不到指定的文件。 (os error 2)

help

第一次接触, Rust 大神在哪里, help me!

阅读 11.2k
5 个回答

安装vs c++,之后再用rustup-init安装一遍,这个时候就能识别link.exe了

MSVC builds of Rust additionally require an installation of Visual Studio 2013 (or later)

新手上路,请多包涵

link.exe没有添加到环境变量中去所以出错。
我的做法是从“vs2013开发人员命令提示”进入。

如果你Linux , 安装 build-essential

sudo apt-get install build-essential

如果是windows ,安装VS 2013 +

出现这个问题是MSVC的环境变量没有添加,安装VS2019之后,在CMD中运行下面的指令添加环境变量
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

编译时指定64位编译器
cargo build --target x86_64-pc-windows-msvc

运行
cargo run

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进