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!
  • 55
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值