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.