1

I'm testing the feasibility of using MSBuild to perform an ARM build of an existing C++ project for Windows Phone and Windows Store. On Windows 7 with VS2012, I opened a Visual Studio 2012 ARM Developer Command Prompt. Then I tried it to see what would happen:

C:\cryptopp>msbuild /t:Build /p:Configuration=Debug;Platform=ARM cryptlib.vcxproj
Microsoft (R) Build Engine version 4.6.1055.0

Build started 10/6/2016 1:11:47 PM.
The target "Midl" listed in a BeforeTargets attribute at "C:\Program Files (x86
)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\masm.targets (28,5)" does
 not exist in the project, and will be ignored.
The target "CustomBuild" listed in an AfterTargets attribute at "C:\Program Fil
es (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\masm.targets (29,5
)" does not exist in the project, and will be ignored.
Project "C:\cryptopp\cryptlib.vcxproj" on node 1 (Build target(s)).
C:\cryptopp\cryptlib.vcxproj : error MSB4057: The target "Build" does not exist 
in the project.
Done Building Project "C:\cryptopp\cryptlib.vcxproj" (Build target(s)) -- FAILE
D.

Build FAILED.

"C:\cryptopp\cryptlib.vcxproj" (Build target) (1)
->
  C:\cryptopp\cryptlib.vcxproj : error MSB4057: The target "Build" does not exi
st in the project.

    0 Warning(s)
    1 Error(s)

I also tired adding the following to cryptlib.vcxproj, but it resulted in the same error.

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

Based on the errors above, I'm not sure if MSBuild supports ARM or if something else is wrong. I get similar results when testing on Windows 8 with VS2013. The similar result is another failure with a different error message.

Does the error message The target "Build" does not exist in the project mean MSBuild does not support ARM? Can MSBuild be used to build a C++ project under ARM?

jww
  • 97,681
  • 90
  • 411
  • 885
  • I created a windows store app via VS 2012, then run msbuild command as yours through VS2012 ARM Cross Tools Command Prompt, it works fine. There isn't Visual Studio 2012 ARM Developer Command Prompt, what's the result if you run MSbuild command through VS2012 ARM Cross Tools Command Prompt? – starian chen-MSFT Oct 07 '16 at 06:20
  • @starain - Sorry for the confusion. The results are from the *"VS2012 ARM Cross Tools Command Prompt"*. As far as I know, there are no native ARM command prompts (corrections, please). – jww Oct 07 '16 at 06:41
  • What project template you used? Provide the detail steps to create project. My steps: Open VS 2012=>File=>New project=>Select Windows Store in Visual C++ section=>Select Blank App (XAML) – starian chen-MSFT Oct 07 '16 at 06:44
  • @starain - No templates; the `*.proj` files were effectively re-written by hand. We started with old Visual Studio project files up-converted with VCUgrade. We then streamlined them from 100KB+ down to about 10KB. They are very terse now, and they only include the minimum required to achieve goals. – jww Oct 07 '16 at 06:49
  • @starain - The detailed steps to reproduce are quite easy: `git clone https://github.com/weidai11/cryptopp.git`. Open `cryptlib.vcxproj` and add the two `ProjectConfiguration` beneath the existing X86 and X64 ones. Then try to build from the ARM developer command prompt. – jww Oct 07 '16 at 06:51
  • Msbuild basically suports any arbitrary platform as long as the it's installed/configured properly. Don't have ARM toolset to test here but either your ARM toolset installation is corrupt or your project file, for example before you have conditions somewhere based on platform but ARM is never considered. To check your toolset do as starain suggests: try a new empty project. – stijn Oct 07 '16 at 07:28
  • @stijn - Thanks. I'm fairly certain the ARM tools are installed and working properly. I use another file, [`cryptest.nmake`](http://github.com/weidai11/cryptopp/blob/static/cryptest.nmake), to build the library under ARM using Nmake. The issue seems to be related to MSBuild. – jww Oct 07 '16 at 07:44
  • @stijn - I can't ask this in the regular question... Where are the Microsoft docs for adding a new platform, like ARM? The obvious way of adding a new `ProjectConfiguration` with the new `Platform` does not appear to work. I can't help but wonder... why is this stuff so difficult. This is the basic, CompSci 101 stuff. There's no reason for it to be difficult. – jww Oct 07 '16 at 18:16
  • @starain - the reason you and I are arriving at different results is you are using C#, while I am using C++. I corrected the title to avoid confusion. I'm fairly certain things are broken with respect to C++ and ARM. I encounter problems in both VS2012 and VS2013. The same problems were reported on XDA forums a few years ago. User Notlikethat is experiencing the same problems while trying to work [Cannot add ARM Platform to existing MSBuild Project](http://stackoverflow.com/q/39924585) with me. These toolschains are broke, and its probably the reason MS has not published procedures. – jww Oct 08 '16 at 04:45
  • *Where are the Microsoft docs for adding a new platform,* why do you think you can't ask this in a regular question? Would be interesting to find out. Anyway I don't know where they are, I sucpect they are something-subscriber-only or so, or else non-existing. However also not extremely hard to figure out since 1) I've seen companies add other platforms b) afaik it's just a matter of having the correct files in, for example, C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms – stijn Oct 08 '16 at 08:12
  • That message indicates that you are using assembly language in the project, which is not portable to ARM platform. You'd better convert them to equivalent C code, remove the assembly related things, and then cross compile to ARM. – Lex Li Oct 09 '16 at 01:35
  • @stijn - *"why do you think you can't ask this in a regular question ..."* - We are not allowed to ask for offsite resources. There's a specific *Close Reason* for it: *"Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it."*. – jww Oct 09 '16 at 03:16
  • Thanks @LexLi. Prior to this experiment I worked a ticket that guarded all of the X86/X64 ASM: [Issue 316: Visual Studio projects include X86/X64 ASM for ARM-based MSBuilds](http://github.com/weidai11/cryptopp/issues/316). Would you happen to know how to pinpoint the offender? `/verbosity:detailed` and `/verbosity:diagnostic` does not reveal it. – jww Oct 09 '16 at 04:05
  • @jww use Message task to generate your own log entries around the key steps to see what exactly happened during compilation. That might tell you more than the default trace of MSBuild. https://msdn.microsoft.com/en-us/library/6yy0yx8d.aspx – Lex Li Oct 09 '16 at 05:48

1 Answers1

2

Yes, this is absolutely possible.

The build system for libvpx generates vcxproj/sln files, including support for the ARM platform, and these can be built both with msbuild.exe or opened in Visual Studio.

The script that generates the project files can be found at https://chromium.googlesource.com/webm/libvpx/+/8b5eddf709b/build/make/gen_msvs_vcxproj.sh. If you want to try it out for yourself (to look at the actual generated project files), clone libvpx, and generate the visual studio project files (targeting Visual Studio 2012) like this (within an MSYS shell, in a directory outside of the libvpx directory):

../libvpx/configure --target=armv7-win32-vs11
make

(It might also work if you just run this within the libvpx directory with ./configure, but I only verified it in a separate directory.)

The make step will also invoke msbuild.exe if found in the path. If not, open a separate shell where you've got msbuild.exe in the path, and build it like this:

msbuild vpx.sln -m -t:Build -p:Configuration=Release -p:Platform=ARM
mstorsjo
  • 12,983
  • 2
  • 39
  • 62
  • Thanks @mstorsjo. I'll need a few days to test it. I'll get back with an accept. Please forgive my ignorance.. strictly speaking, does `make` need to be run? It seems like `configure` is where the build artifacts drop out. If I do need to run `make`, then do I open an ARM Developer Command Prompt? Or does a regular command prompt work? – jww Oct 08 '16 at 19:26
  • Yes, that's the way it'd work in many build systems. But the libvpx build system works a bit differently; configure just creates a few makefiles, that describe how to generate the visual studio project files. You don't need to open the ARM Developer Command Prompt for this, you need to run the configure and make steps in an MSYS (or equivalent, I think cygwin also works) shell. If msbuild is available here, it'll be invoked automatically, otherwise you need to run the last step manually in an ARM Developer Command Prompt. – mstorsjo Oct 08 '16 at 20:20