Unable to compile Rust hello world on Windows: linker link.exe not found

后端 未结 5 2193
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 08:31

I have installed Rust on windows from Rust installation page. After installation I tried running the \"hello world\" program but got the following error.



        
5条回答
  •  悲&欢浪女
    2020-12-13 09:19

    I had the same issue and found it to be present even after installing the Build Tools. What I realized almost by accident that I was running all my cargo commands in "Developer Command Prompt for Visual Studio ". Running the same commands in a simple cmd shell ran without any issues.

    What worked for me: Running the command prompt directly and not use the shortcuts created by Visual Studio.

    Possible Cause: Visual Studio Command Prompt runs bat files e.g. VsDevCmd.bat before it starts the shell (to load VS related environment variables, etc.) and possibly one of the commands in that file screws up the path cargo uses to get to linker.

    Someone could dig further to find the exact line that causes the issue if they really want to know.

提交回复
热议问题