Visual Studio Platform 2015 Toolset ='v141' cannot be found
Asked Answered
D

6

36

I'm trying to compile a project using OpenFrameworks (a library which uses C++) in Visual Studio. The build is set to Release and X64 and in the project properties I have set the Platform Toolset to Visual Studio 2015 (v140)

However every time I try to build the project I get the same error (amongst others)

Error MSB8020 The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools.

I know v141 is from the new version of MSVS 2017 but I do not want to upgrade to as the new version is not compatible with OpenFrameworks. I have tried rebuilding the project from scratch several times and have also looked into the VCXPROJ file and verified that everything is set to V140 - and it is. All very bizarre.

It seems that on build, something is setting a requirement for v141 but I cannot seem to find where this is coming from. Does anyone have an idea?

Diehl answered 9/4, 2017 at 22:37 Comment(6)
Someone asked a similar question to yours here.Quantitative
thanks but as i mentioned i tried both those fixes (that i knew about) namely, changing the platform toolset in properties and editing the vcxproj fileDiehl
Have you also modified the Target Platform Version to 8.1?Publicspirited
I'm looking for a similar fix but have not tried any of them yet because how do I know they work? It seems to want something that is not installed. I'm looking for that but I just installed build tools for VS 2015 and that did nothing. I could let it run repair but it takes so long. What is MS's game here? I haven't even had this for a year and now 2017?Ieper
Try to do a clean checkout of your code so all VS generated files are gone. Alternatively, try to do a text based search in all files in your build directory for 141, perhaps you can find the cause like that.Acquaint
Did you also set the ToolsVersion to 14.0 in the vcxproj?Galvani
K
26

I had such an issue. The solution is: open menu "Project"->Properties->Configuration Properites->General - and choose platform toolset v140.

Klump answered 6/3, 2018 at 6:32 Comment(0)
V
11

Had this same error trying to npm install after cloning a node based project. It had an npm dependency that required C++ source to be compiled.

I had already modified my VS2017 install to include Individual Components -> VC++ 2017 version 15.7 v14.14 latest v141 tools

but that didn't help.

I applied these commands in succession

  1. npm install -g node-gyp

  2. npm install --global --production windows-build-tools

The first had no effect but the second did the trick and the npm install command completed successfully after that.

Vane answered 4/6, 2018 at 5:16 Comment(2)
...this was extremely helpful and extremely nailed onDisability
Of further note, when setting up a TeamCity machine I had a lot of headache. Did the above but also uninstalled/reinstalled the Visual C++ build tools workload and wiped out the VCTargetsPath environment variable other googling suggested to set itVane
K
6

This was addressed in the comments of one of the answers, but it worked for me. I had both v140 and v141 build tools installed, so when I had to use v140 build tools for something, I set the VCTargetsPath variable to the path of the v140 build tools. Deleting this variable in my environment variables ultimately fixed this issue for me.

enter image description here

Kreit answered 9/3, 2019 at 21:59 Comment(0)
S
4

For this error, and similar, for other platforms (e.g. VS2013) this problem typically occurs because you installed an older version of VS after you installed a later one. It's my observation that this will effect all of your Visual Studio C++ projects, and you will have to manually set them to target the specific toolset for the given version of VS you are trying to build the project under.

Snowball answered 22/3, 2018 at 14:10 Comment(2)
Yes this was indeed the case, fixed this a while back without checking back on the status of this question as I'd given up hope.Diehl
Indeed this is the real reason. Just fixed it by the posted solution, thanks.Hanley
O
1

enter image description here

If anyone has the same issue.. Reason: When someone tries to open existing solution which created/build on latest VS version (VS2015 / 2017) and tried to open with backward / old version of VS instance. Then this error might occur.

Please try below steps. Right click Project->Properties->Configuration Properties. Set 'Target Platform Version' as Supported OS version, i.e. for 8.1 > Win7 & 10 Win10 Set 'Platform tool set' as installed visual studio version.

Re-Build & Enjoy :)

Osborn answered 15/4, 2020 at 6:25 Comment(0)
D
0

I had that v141 error when building from command-line but not inside visual studio:

The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".

Turns out it was because I was calling the wrong vcvars so I was using the wrong version of msbuild.exe:

:: wrong (Visual Studio 2015)
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 >NUL
:: correct (Visual Studio 2017)
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" x64 >NUL

Not sure it's possible for this to be the error inside visual studio, but I hope this is helpful to some future searcher...

Deadeye answered 23/7, 2021 at 17:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.