0

I'm trying to add ARM platform support to an existing Visual C++ project. I want to ensure the project can build Windows Phone and Windows Store apps in addition to X86 and X64 programs.

Microsoft does not appear to provide official documentation on the subject matter (or I can't seem to find it). In the absence of official documentation, I'm following the discussion provided on Microsoft Blogs at A guide to .vcxproj and .props file structure. I think the blog is quite good, and I don't think it has any defects, errors or omissions.

lib.vcxproj is an MCVE and its shown below. When I build an X86 or X64 target using a Visual Studio C++ project file from a VS{2010|2012|2013} X86 or X64 Developer Command Prompt, then things work as expected:

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)

When I uncomment the ARM specific gear:

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

Then switch to a ARM Developer Command Prompt and attempt to build it, the result is a failure:

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)

All the ARM tools are installed correctly. I regularly build the project from the command line with Nmake using an ARM Developer Command Prompt.

According to the feedback at Can MSBuild be used to build a C++ project under ARM?, MSBuild does support ARM.

According to Difference between 2003 and current MSBuild schemas, I should continue to use the 2003 version of the schema.

How do I add ARM Platform support to existing Visual C++, MSBuild-based Project?


If you receive the "Compiling desktop applications for the ARM platform is not supported" error message, then add the following:

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

It can be added to the ItemDefinitionGroup for ARM, near the PrecomiledHeader option.


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>

No, this is not a duplicate. See the comment that explains why.

11
  • 2
    Are you really adding those ProjectConfiguration elements outside the ItemGroup containing the existing ones? I don't even need to look at the error message or the schema to suspect an obvious problem there... There's also always the option of just firing up VS and adding a new platform via the configuration manager to see how that works out. Oct 7, 2016 at 21:03
  • Good catch @Notlikethat - Yes, its wrong in the MCVE. Its now fixed. Its correct in the MCVE and real project, and it still produces the errors.
    – jww
    Oct 7, 2016 at 21:22
  • Well, for me, fixing that results in at least a different error; the good old "Compiling desktop applications for the ARM platform is not supported" (admittedly I'm not actually using VS2010, and had to hack PlatformToolset to "v110" to get that far under the VS2012 command prompt from whatever Windows Phone SDK was installed by VS2015). At worst, there's always the option of firing up VS itself, adding a new platform to the project through the configuration manager, and seeing the difference that makes. Oct 7, 2016 at 21:54
  • 1
    @stijn - Not a duplicate. I try to ask concise questions. The dup you cited asks if its possible. This questions asks how to accomplish it. This question also provides an MCVE attempting to demonstrate it. They are two different questions building on one another.
    – jww
    Oct 8, 2016 at 8:29
  • 1
    Thanks @stijn. I'm familiar with the question Can ARM desktop programs be built using visual studio 2012? It misses the mark because its WinRT/ARM, and only Microsoft is allowed to do anything useful with it. WindowsSDKDesktopARMSupport and WinRT are not the solution to any problem because its Microsoft exclusive. I know the details because I bought and tested the WinRT tablet; and I worked feature request for improved Windows Phone, Windows Store and UWP support.
    – jww
    Oct 8, 2016 at 9:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.