Gri*_*son 5 c++ visual-studio-2010 visual-studio visual-studio-2015
我的老师很想在学校使用Visual Studio 2010,因为他们不想打扰安装任何新东西.我一直在使用Visual Studio 2015,我真的很喜欢它.但是,当她尝试运行任何代码时,会产生一堆错误.我尝试了通过编辑解决方案文件使2013/2012项目与2010兼容的解决方案,但它仍然会产生错误.有解决方案吗?
当我尝试在Visual Studio 2010中运行源文件时,这是控制台输出:
1>------ Build started: Project: typingSalon, Configuration: Debug Win32 ------
1>Build started 4/8/2015 8:19:30 AM.
1>Project file contains ToolsVersion="14.0". This toolset is unknown or missing. You may be able to resolve this by installing the appropriate .NET Framework for this toolset. Treating the project as if it had ToolsVersion="4.0".
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(518,5): error MSB8008: Specified platform toolset (v140) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.05
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)
如果您只使用Visual Studio IDE本身(而不是命令行上的MSBuild)进行编译,您可以实际工作,只需进行一些更改,在两个平台上都可以使用或多或少的完整功能.
不幸的是,C++项目的规则与C#/ .NET不同,并且需要一些人工干预,不像C#项目在项目"升级"之后相当自动地进行往返.这些更改将需要手动编辑项目文件.
在通过IDE运行构建时,Visual Studio的更高版本将覆盖工具版本.简单地设置ToolsVersion为4.0,以满足Visual Studio 2010,然后修复PlatformToolset公共属性组以在Visual Studio 2015 IDE中获取正确的默认操作可能会这样做.
设置的原因PlatformToolset是在更改构建属性时正确的默认值,例如当您转到IDE Debug或Release在IDE中进行设置并选择时<inherit from parent or project defaults>,默认情况下将获得2015版本,而不是2010年.
Visual Studio 2010,Visual Studio 2015和Visual Studio 2017同步在C++的同一项目文件中的步骤:
1.工具版本到4.0:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
...
Run Code Online (Sandbox Code Playgroud)
通过仅更改14.0到4.0在Project为标签ToolsVersion就变成
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
...
Run Code Online (Sandbox Code Playgroud)
2.将PlatformToolset的常见默认值添加到仅由Visual Studio 2015识别的v140:
<PropertyGroup Label="Globals">
<ProjectGuid>{12345678-9876-ABCD-DCCA-765FE987AA1F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>myProject</RootNamespace>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Run Code Online (Sandbox Code Playgroud)
通过仅将新PlatformToolset行添加到其底部PropertyGroup变为:
<PropertyGroup Label="Globals">
<ProjectGuid>{12345678-9876-ABCD-DCCA-765FE987AA1F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>myProject</RootNamespace>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Run Code Online (Sandbox Code Playgroud)
要在Visual Studio 2017中加载,v141还需要一个带有工具集的行,如上所示,以继续在这三者之间无缝地交叉加载项目.
问题在于项目文件引用了v140C++ 工具集,这基本上意味着使用 Visual Studio 2015 中的 C++ 编译器。未安装此编译器,这会导致您出现错误消息。
从我的想法来看,有两种方法可以帮助你克服目前的情况:
在计算机上安装 Visual Studio 2010。然后,从 2015 年开始,在项目设置中选择 2010 平台工具集。这样,您的项目将始终使用 2010 进行编译,但您的优势是不会意外使用 2010 所没有的 C++ 功能。
不要在计算机上安装 Visual Studio 2010,而是使用第二台计算机(仅安装了 2010)创建第二个生成配置,该配置的平台工具集设置为 Visual Studio 2010 (v100)。根据您使用的 Visual Studio 使用适当的配置。
这两种解决方案基本上意味着您不使用 Visual Studio 2015 相对于 Visual Studio 2010 改进的 C++ 功能,这有点不幸。
| 归档时间: |
|
| 查看次数: |
19980 次 |
| 最近记录: |