VS2015編譯報錯:error MSB8020
提示信息: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. 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”.
原因分析
根據報錯信息很清楚地看到就是構建工具的平臺版本不匹配,即我拿的是別人在VS2017的工程,但是我本地是VS2015的工程,這兩個工程配置差異導致的構建失敗。
解決方案
打開VS2015項目-項目-屬性-常規-平臺工具集,修改成你本地對應的就可以,以VS2015為例,應該是VS2015(v140),截圖如下:
修改完成后還出現另一個報錯:error MSB8036: The Windows SDK version 10.0.17763.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting “Retarget solution”.
原因分析
與上面分析一致,也是平臺不匹配導致。
解決方案
- 重新裝一個匹配版本的VS,例如工程原先是VS2017的,那就安裝對應的VS;
- 修改當前項目的配置屬性:項目-屬性-常規-目標平臺版本,改成本地對應的就行,以我本地為例,我是用VS2015,所以我改成了8.1版本(VS2017應該是10.1),截圖如下:
結果展示
編譯成功,正常生成lib文件: