Saturday, June 3, 2017

I have started learning Rust programming language since months before but in slow pace. I wanted to take back the track after formating my laptop and reinstalling windows, I decided to install Visual Studio 2017 community edition instead of 2015 since I am a C# developer and I wanted to experience dotnet core and ASP.net 5, aka ASP.NET core.
My previous Rust environment setup with VC++ 2015 was working perfect without issues, but when I tried to do the same with VC++ 2017 I run into several issues. According to this thread in Github it is due to the change that Microsoft did in folder structure in the new version, which is not supported by current stable version of rustc. A patch is has already been committed to the compiler repository and it will be released in the next version 1.18.
The actual issue with compilation is inability to find the link.exe when running rustc or cargo due to the change mentioned above as shown in the illustration below.
Issue occurring when compiling with VC++ 2017 tools
To remedy this issue follow these steps
  1. Download Visual studio build tools from this link
  2. Launch to install and select the following options as shown in the illustration below
    1. Visual C++ build tools
    2. Visual C++ tools for CMake
    3. Windows 8.1 SDK and UCRT SDK or Windows 10 SDK 
  3. Then click install (Installation might take some time to complete)
  4. Once installation is done, navigate to C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build from your command line and run vcvarsXX.bat where XX is your target build architecture (32/64 bit)
  5. You will get a message [vcvarsall.bat] Environment initialized for: 'xXX'
  6. Navigate back to your project root directory and run cargo run
Yatta! it's now working.
Since I am using Intellij with for my Rust programmings I launched it from the command line instance which has environment variables set, solved also the compilation issue in it.
PS: Make sure to include Universal C runtime in the installation to avoid another compilation error related to ucrt.lib not found.

Happy coding, Rustaceans!

EDIT

The last nightly version seem to have solved this issue, which is 1.19.0-nightly (3d5b8c626 2017-06-09) use rustup tool to switch between toolchain versions.

Edit 2 - 2017/07/25 @ 13:16

Current stable version have this error fixed, please see Rust blog for details

0 comments:

Post a Comment