error: linker `link.exe` not found

Posted 境悟初

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了error: linker `link.exe` not found相关的知识,希望对你有一定的参考价值。

Rust在windows下第一课,编译报错:

cargo build
   Compiling rsj-kv v0.1.0 (D:\\workspace\\git\\rsj-kv)
error: linker `link.exe` not found
  |
  = note: 系统找不到指定的文件。 (os error 2)

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option

error: could not compile `rsj-kv` due to previous error

错误信息很明显:依赖于微软的 msvc linker.exe

一般让去下载VS,不过可以直接用rust命令解决。

 rustup toolchain install stable-x86_64-pc-windows-gnu
 rustup default stable-x86_64-pc-windows-gnu

完整运行过程:

PS D:\\workspace\\git\\rsj-kv\\src> rustup toolchain install stable-x86_64-pc-windows-gnu
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: latest update on 2021-12-02, rust version 1.57.0 (f1edd0429 2021-11-29)
info: downloading component 'cargo'
  7.0 MiB /   7.0 MiB (100 %)   1.6 MiB/s in  4s ETA:  0s
info: downloading component 'clippy'
  3.4 MiB /   3.4 MiB (100 %)   1.6 MiB/s in  2s ETA:  0s
info: downloading component 'rust-docs'
 17.8 MiB /  17.8 MiB (100 %)   1.2 MiB/s in 13s ETA:  0s
info: downloading component 'rust-mingw'
  4.2 MiB /   4.2 MiB (100 %)   1.7 MiB/s in  2s ETA:  0s
info: downloading component 'rust-std'
 34.0 MiB /  34.0 MiB (100 %)   1.6 MiB/s in 21s ETA:  0s
info: downloading component 'rustc'
141.0 MiB / 141.0 MiB (100 %)   1.3 MiB/s in  1m 36s ETA:  0s
info: downloading component 'rustfmt'
  6.2 MiB /   6.2 MiB (100 %)   1.6 MiB/s in  4s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 17.8 MiB /  17.8 MiB (100 %)   1.9 MiB/s in  6s ETA:  0s
info: installing component 'rust-mingw'
  4.2 MiB /   4.2 MiB (100 %)   3.9 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 34.0 MiB /  34.0 MiB (100 %)  14.1 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
141.0 MiB / 141.0 MiB (100 %)  13.5 MiB/s in 10s ETA:  0s
info: installing component 'rustfmt'

  stable-x86_64-pc-windows-gnu installed - rustc 1.57.0 (f1edd0429 2021-11-29)

info: checking for self-updates
PS D:\\workspace\\git\\rsj-kv\\src> rustup default stable-x86_64-pc-windows-gnu
info: using existing install for 'stable-x86_64-pc-windows-gnu'
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'

  stable-x86_64-pc-windows-gnu unchanged - rustc 1.57.0 (f1edd0429 2021-11-29)

PS D:\\workspace\\git\\rsj-kv\\src> cargo build
   Compiling rsj-kv v0.1.0 (D:\\workspaced\\git\\rsj-kv)
    Finished dev [unoptimized + debuginfo] target(s) in 1.49s
PS D:\\workspace\\git\\rsj-kv\\src> cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `D:\\workspace\\git\\rsj-kv\\target\\debug\\rsj-kv.exe`
Hello, world!

以上是关于error: linker `link.exe` not found的主要内容,如果未能解决你的问题,请参考以下文章

易语言无法定位链接器!请检查 tools\link.ini 中的配置是不是正确。

c++调试LINK : fatal error LNK1104: cannot open file "Debug/a.exe" 执行 link.exe 时出错.

c++调试LINK : fatal error LNK1104: cannot open file "Debug/a.exe" 执行 link.exe 时出错.

小白求教静态编译提示无法定位连接器怎么搞

易语言的VC6 链接器-超级迷你版怎么用

python pcapy 安装错误 link.exe failed with exit status 1120