无法将ARM平台添加到现有MSBuild项目

时间:2016-10-07 19:32:17

标签: windows visual-studio msbuild arm

我试图将ARM平台支持添加到现有的Visual C ++项目中。我想确保除了X86和X64程序之外,该项目还可以构建Windows Phone和Windows应用商店应用程序。

Microsoft似乎没有提供有关主题的官方文档(或者我似乎无法找到它)。在没有官方文档的情况下,我跟随微软博客A guide to .vcxproj and .props file structure提供的讨论。我认为博客非常好,而且我认为它没有任何缺陷,错误或遗漏。

lib.vcxproj MCVE,如下所示。当我使用VS {2010 | 2012 | 2013} X86或X64开发人员命令提示符中的Visual Studio C ++项目文件构建X86或X64目标时,事情按预期工作:

c:\Users\Test>msbuild /t:Build /p:Configuration=Debug;Platform=x64 lib.vcxproj
Microsoft (R) Build Engine version 4.6.1055.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 10/7/2016 3:03:15 PM.
Project "c:\Users\Test\lib.vcxproj" on node 1 (Build target(s)).
...

Done Building Project "c:\Users\Test\lib.vcxproj" (Build target(s)).

Build succeeded.
    0 Warning(s)
    0 Error(s)

当我取消注释ARM特定的齿轮时:

<ProjectConfiguration Include="Debug|ARM">
  <Configuration>Debug</Configuration>
  <Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
  <Configuration>Release</Configuration>
  <Platform>ARM</Platform>
</ProjectConfiguration>

然后切换到ARM Developer命令提示符并尝试构建它,结果是失败:

c:\Users\Test>msbuild /t:Build /p:Configuration=Debug;Platform=ARM lib.vcxproj
Microsoft (R) Build Engine version 4.6.1055.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 10/7/2016 7:43:12 PM.
Project "c:\Users\Test\lib.vcxproj" on node 1 (Build target(s)).
c:\Users\Test\lib.vcxproj : error MSB4057: The target "Build" does not exist in 
the project.
Done Building Project "c:\Users\Test\lib.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

"c:\Users\Test\lib.vcxproj" (Build target) (1) ->
  c:\Users\Test\lib.vcxproj : error MSB4057: The target "Build" does not exist i
n the project.

    0 Warning(s)
    1 Error(s)

所有ARM工具都已正确安装。我使用ARM Developer命令提示符使用 Nmake 从命令行定期构建项目。

根据Can MSBuild be used to build a C++ project under ARM?的反馈,MSBuild确实支持ARM。

根据Difference between 2003 and current MSBuild schemas,我应该继续使用2003版本的模式。

如何向现有的基于MSBuild的Visual C ++项目添加ARM平台支持?

如果您收到&#34;不支持为ARM平台编译桌面应用程序&#34; 错误消息,请添加以下内容:

<ClCompile>
  <PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>

可以在ItemDefinitionGroup选项附近添加到ARM的PrecomiledHeader

lib.cpp

// One symbol
static const int s_int = 1;

lib.vcxproj

<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>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>

    <!-- BEGIN Added for ARM -->
    <!--
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    -->
    <!-- END Added for ARM -->
  </ItemGroup>
  <PropertyGroup Label="Globals">
      <ProjectGuid>{111111-1111-1111-1111-111111111111}</ProjectGuid>
      <RootNamespace>test</RootNamespace>
      <PlatformToolset>v100</PlatformToolset>
      <ConfigurationType>StaticLibrary</ConfigurationType>
    </PropertyGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

  <ImportGroup Label="ExtensionSettings" />
  <ImportGroup Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />

  <!-- X86 Configurations -->
  <ItemDefinitionGroup Condition="'$(Platform)'=='Win32'" Label="X86 Configuration">
    <ClCompile>
      <PrecompiledHeader />
    </ClCompile>
    <Lib>
      <TargetMachine>MachineX86</TargetMachine>
      <ImageHasSafeExceptionHandlers>true</ImageHasSafeExceptionHandlers>
    </Lib>
  </ItemDefinitionGroup>

  <!-- X64 Configurations -->
  <ItemDefinitionGroup Condition="'$(Platform)'=='x64'" Label="X64 Configuration">
    <ClCompile>
      <PrecompiledHeader />
    </ClCompile>
    <Lib>
      <TargetMachine>MachineX64</TargetMachine>
    </Lib>
  </ItemDefinitionGroup>  

  <!-- ARM Configurations -->
  <ItemDefinitionGroup Condition="'$(Platform)'=='ARM'" Label="ARM Configuration">
    <ClCompile>
      <PrecompiledHeader />
    </ClCompile>
    <Lib>
      <TargetMachine>MachineARM</TargetMachine>
    </Lib>
  </ItemDefinitionGroup>

  <ItemGroup>
    <ClCompile Include="lib.cpp" />
  </ItemGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

不,这不是重复的。请参阅comment that explains why

0 个答案:

没有答案