C++ 如何在 Visual Studio 2015 社区上安装 Visual Studio Build Tools 2010?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34885286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 14:27:08  来源:igfitidea点击:

How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?

c++visual-studiovisual-studio-2010visual-studio-2015vs-community-edition

提问by Gal Fridman

I have a project created on Visual Studio 2010. When I try to run the project on Visual Studio 2015 Community edition I get the error below,

我在 Visual Studio 2010 上创建了一个项目。当我尝试在 Visual Studio 2015 社区版上运行该项目时,出现以下错误,

Severity Code Description Project File Line Error MSB8020 The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 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". graphics C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets 55

严重性代码描述项目文件行错误 MSB8020 找不到 Visual Studio 2010 的构建工具(平台工具集 = 'v100')。要使用 v100 构建工具进行构建,请安装 Visual Studio 2010 构建工具。或者,您可以通过选择“项目”菜单或右键单击解决方案,然后选择“重定向解决方案”来升级到当前的 Visual Studio 工具。图形 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets 55

And when I tried to build it with Visual Studio 2015 Build Tools I encountered about 1500+ errors.

当我尝试使用 Visual Studio 2015 Build Tools 构建它时,我遇到了大约 1500 多个错误。

enter image description here

在此处输入图片说明

Is there any way to make the project work?

有什么办法可以使项目工作吗?

回答by Paul

If you can't install VS2010, Windows SDK for Windows 7contains needed compiler tools (v100), you may actually skip installing the SDK itself and install only the compiler tools, headers and libs. Please note, that the compiler included in Windows SDK is the same that VS2010 has, but VS2010 SP1 has a bit newer compiler. If you need that, you'll also need to install Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1. But be aware, that if you install these, you may have issues later if you decide to install VS2010, there are bugs in installer that requires you to install components in strict order. Also, if your code uses MFC or ATL you must install VS2010, installing Windows SDK will not be enough.

如果您无法安装 VS2010,Windows 7 的 Windows SDK包含所需的编译器工具 (v100),您实际上可以跳过安装 SDK 本身,只安装编译器工具、头文件和库。请注意,Windows SDK 中包含的编译器与 VS2010 相同,但 VS2010 SP1 的编译器要更新一些。如果需要,您还需要为 Windows SDK 7.1安装Microsoft Visual C++ 2010 Service Pack 1 编译器更新。但是请注意,如果您安装了这些,以后如果您决定安装 VS2010,您可能会遇到问题,安装程序中存在错误,需要您按照严格的顺序安装组件。此外,如果您的代码使用 MFC 或 ATL,则必须安装 VS2010,安装 Windows SDK 是不够的。

回答by Chuck Walbourn

You either install VS 2010 and build your project, or better yet you upgrade your projects. The VS 2015 custom install options will let you install the v120Platform Toolset, but not the v110or v100Platform Toolsets.

您要么安装 VS 2010 并构建您的项目,要么升级您的项目更好。在2015年VS自定义安装选项可以让你安装v120平台工具集,而不是v110v100平台的工具集。

One major change in VS 2015 is that the C++ tools (i.e. v140) are not installed by the Typical installation option. See the Visual C++ Team Blog.

VS 2015 中的一项主要变化是 C++ 工具(即v140不是通过典型安装选项安装的。请参阅Visual C++ 团队博客

Keep in mind that Visual C++ 2010 used the C++0x Draft Standard, and Visual C++ 2015 meets the C++11 Standard with the exception of Expression SFINAE (which is partly there in Update 1), so quite a bit has changed in the intervening years including some breaking changes. Since you are jumping three major releases at once--and about 10 minor updates--, it can be a bit overwhelming especially working through all the new warnings.

请记住,Visual C++ 2010 使用了 C++0x 草案标准,并且 Visual C++ 2015 符合 C++11 标准,但 Expression SFINAE(更新 1 中的一部分)除外,因此在中间几年,包括一些重大变化。由于您一次跳过三个主要版本——以及大约 10 个次要更新——,尤其是在处理所有新警告时可能会有点不知所措。

Another thing to keep in mind is that Visual C++ 2010 used the Windows 7.1 SDK, while Visual C++ 2012 or later use the Windows 8.x SDK. There's been a lot of change there too particularly for DirectX development. It's particularly important for Windows desktop apps that you set the _WIN32_WINNTpreprocessor define for your target platform as the Windows 8.x SDK does not default to the 'oldest supported platform' like earlier Windows SDKs did. See Using the Windows Headers

要记住的另一件事是,Visual C++ 2010 使用 Windows 7.1 SDK,而 Visual C++ 2012 或更高版本使用 Windows 8.x SDK。那里也有很多变化,特别是对于 DirectX 开发。_WIN32_WINNT对于为目标平台设置预处理器定义的Windows 桌面应用程序尤其重要,因为 Windows 8.x SDK 不像早期的 Windows SDK 那样默认为“最旧的支持平台”。请参阅使用 Windows 标头

VS 2010 and the v100toolset supports targeting Windows XP and Windows Server 2003. The v140toolset does not support targeting Windows XP / Server 2003. You have to use v140_xpPlatform Toolset instead. See this postfor some notes as this means you are again using the Windows 7.1 SDK rather than the Windows 8.x SDK with the _xptoolsets.

VS 2010 和v100工具集支持面向 Windows XP 和 Windows Server 2003。v140工具集不支持面向 Windows XP / Server 2003。您必须改用v140_xp平台工具集。有关一些说明,请参阅此帖子,因为这意味着您将再次使用 Windows 7.1 SDK 而不是带有_xp工具集的 Windows 8.x SDK 。

See Breaking Changes in Visual C++ 2012, Breaking Changes in Visual C++ 2013, and Breaking Changes in Visual C++ 2015.

重大更改在Visual C ++ 2012重大更改在Visual C ++ 2013重大更改在Visual C ++ 2015年

See also Support For C++11/14/17 Features (Modern C++), and Where is the DirectX SDK?.

另请参阅支持 C++11/14/17 功能(现代 C++),以及DirectX SDK 在哪里?.

If you need to build the code both with VS 2010 and with VS 2015, then you should create two projects/solution files, one for each. You may also want to read this articlefor some notes on writing code that can build with multiple Visual C++ toolsets, which again is particularly challenging due to the Windows SDK changes.

如果您需要使用 VS 2010 和 VS 2015 构建代码,那么您应该创建两个项目/解决方案文件,每个文件一个。您可能还想阅读这篇文章,了解有关编写可以使用多个 Visual C++ 工具集构建的代码的一些注意事项,由于 Windows SDK 的变化,这也特别具有挑战性。

VS 2015 supports targeting Windows Vista SP2, Windows 7 SP1, Windows 8.0, Windows 8.1, Windows 10, and optionally Windows XP SP3. It does notsupport targeting Windows Vista RTM, Windows Vista SP1, or Windows 7 RTM.

VS 2015 支持面向 Windows Vista SP2、Windows 7 SP1、Windows 8.0、Windows 8.1、Windows 10 和可选的 Windows XP SP3。它支持以 Windows Vista RTM、Windows Vista SP1 或 Windows 7 RTM 为目标。