一、问题描述 error: linker link.exe not found
项目运行cargo run时如下报错信息:
(备注 前景信息:windows10系统,新电脑安装rustup,先安装了 c++ build tool gcc 。 cargo new 正常 )
---运行项目控制台信息:
PS C:\MyStudio\rust\hello_world\src> cargo run
Compiling hello_world v0.1.0 (C:\MyStudio\rust\hello_world)
error: linker `link.exe` not found
二、解决方案(搜集于网络
使用rustup 命令就可以解决掉
1、终端先执行如下命令,等待dowload 完成,这一步可能需要一点时间;
rustup toolchain install stable-x86_64-pc-windows-gnu
2、再执行
rustup default stable-x86_64-pc-windows-gnu
三、回顾
貌似在安装rustup的步骤里也有提到过 x86_64-pc-windows-gnu ,但是安装环境也不是经常搞。我在想那一步是不是选择这一项,后面其实就不会报这个错了。当然后续可能还会遇到其他问题,慢慢补吧,今次先这样。
补充2024-3-15 10:55 :运行rustup target list 的时候 我看到了x86_64-pc-windows-gnu(installed),我大概理解为这是rust和本机交叉编译的目标平台。嵌入式开发时的目标平台也是如此,需要安装硬件的目标平台才能进行编译。