Visual Studio 2017: vcvars for toolset v140

Viewed 5343

I installed Visual Studio 2017 and toolsets v140 and v141. To work with v140 toolset, I need to set the necessary environment via vcvars. However, running the necessary vcvars, I get various errors. I am taking vcvars from this directory - C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC - as I need to initiate the environment for the work with v140 toolset.

If I run vcvarsall, for example, then vcvarsall.bat x86 or vcvarsall.bat x86_amd64 - and I get the following error:

Error in script usage. The correct usage is:

vcvarsall.bat [option] or
vcvarsall.bat [option] store or
vcvarsall.bat [option] [version number] or
vcvarsall.bat [option] store [version number]

where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | >amd64_arm
where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK

: The store parameter sets environment variables to support store (rather than desktop) development. :

For example:

vcvarsall.bat x86_amd64
vcvarsall.bat x86_arm store
vcvarsall.bat x86_amd64 10.0.10240.0
vcvarsall.bat x86_arm store 10.0.10240.0
vcvarsall.bat x64 8.1
vcvarsall.bat x64 store 8.1 :

Please make sure either Visual Studio or C++ Build SKU is installed.

If I run a specific file vcvars, for example, vcvars32.bat, then I get another error:

ERROR: Cannot determine the location of the VS Common Tools folder.

Has anyone had the same issue, could you help? Thank you.

4 Answers

As stated in the Microsoft forums here modifying the vcvarsall.bat script seems to solve the issue with latest VS tool installed (it did for my installation)

In case the link goes dead: the solution is to comment line 8 (or 10 depending if there are two blank lines at the beginning of the file)

There is an additional command-line argument for the newer vcvars*.bat files: vcvars_ver.

To setup an enviroment using the VS2015 toolchain with VS2017 one has to append -vcvars_ver=14.0 to the new vcvars*.bat call.

E.g. "c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64 8.1 -vcvars_ver=14.0 sets up an environment for x64 using Windows 8.1 SDK and the MSVC2015 toolchain.

There is no need to change any value in the registry or modify the installed batch files.

Source: https://developercommunity.visualstudio.com/solutions/140023/view.html

The problem line is

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16 10.0.18362.0

I just went to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build and found vcvars64.bat.

After studying it, I modified it like this

REM @call "%~dp0vcvarsall.bat" x64 %*
@call "%~dp0vcvarsall.bat" x64 

getting rid of the offending 14.16 10.0.18362.0 parameter. It worked. No messing up with the register.

Related