Howto: Build your Metro app for ARM & x64

After finding out all I was able to build out were x86 bits I spend last night fixing my game to also run under ARM & x64. What you need are the jpeglib, libxml2, libpng, and zlib static libraries for ARM and/or x64 but since they are not included in the Cocos2d-x Metro solution you can follow the steps below.

Steps,

  1. download the static release libs I created from here: https://github.com/trentmillar/cocos2d-x-metro-static-libs

  2. Using the simple game pathing as an example create an ARM & x64 folder under:
    C:2dxWin8\cocos2dx\platform\third_party\win8_metro\libraries and copy the 4 libs under each folder.

  3. Create both the x64 & ARM configurations in Visual Studio, this explains it better than I could http://www.viva64.com/en/l/0004/ follow steps 1 to 4. Make sure you choose to copy existing settings from the x86 configuration.

  4. Add the library folder to the new configurations.

  • open the property window for your game project in Visual Studio
  • go to “Configuration Properties”>“VC++ Directories”>“Library Directories”
  • add $cocos2dx\platform\third_party\win8_metro\libraries\ARM; Note, change ARM to x64 for the x64 configuration
  • add libpng.lib, libxml2.lib, jpeglib.lib, and zlib.lib to the “Linker”>“Input”>“Additional Dependencies” so they link into the build.

Other possible gotchas-

  • You will probably have issues compiling the hlsl shaders. When you create the new configurations it looks like the build types for these are lost. Make sure you right-click each shader under cocos2dx and change the Shader Type to either pixel or vertex (/ps /vs).

  • The pre-compiled header should not be compiled so make sure you change this in the project properties. This essentially removes the /Yu switch

  • Add the following to the Preprocessor Definitions in the project properties: _CRT_SECURE_NO_WARNINGS

That should be it.

Note, the jpeglib lib I built is probably not the correct version and is missing some methods CCImage was expecting. Since these methods are only called when on a WOPhone I simply removed them from the CCImage class file. I will probably look into this later but for now you need to be aware of this.

Disclaimer,

  • I have not full tested the libs, if you find issues please reply to this post so I can fix and update.
  • I do not have a WinRT ARM tablet to verify the arm libs. If you do can you reply back to let us all know if they worked?
  • I was able to test my game using these libs on x86 and x64 successfully.

happy building!

Does your version of libxml2 pass the Windows App Validation tests? I cannot test for myself because when I try to link your libxml2 version (x86) I get the following error:

libxml2.lib(tree.obj) : error LNK2001: unresolved external symbol _snprintf

My fault

I will delete the x86 libs. They built but were not meant to be used so I’m sure linking was not done properly. I found the included x86 libs were great so use them instead.

The included libs do function properly, bu they do not pass the WACK. I’m now trying to strip down libXML to get it to pass WACK (tinyXML appears to be way too slow for my purpose).

Strange. Can you send me the report that is generated.

◦API CreateMutexA in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API GetModuleFileNameA in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API GetModuleHandleA in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API GetVersionExA in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API InitializeCriticalSection in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API Sleep in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API TlsAlloc in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API TlsGetValue in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API TlsSetValue in kernel32.dll is not supported for this application type. HDXP.exe calls this API.
◦API WaitForSingleObject in kernel32.dll is not supported for this application type. HDXP.exe calls this API.

Currently I’ve a version that only has one problem left:
◦API GetVersionExA in kernel32.dll is not supported for this application type. HDXP.exe calls this API.

Going to fix that now…

You ran the certification test using the x64 libs? When I did there were no issues with the certification nor running my game. I have since uploaded my game to the App Store using the x64 and ARM libs and so far the game has passed the first three or four checks. Just waiting on the manual content test to pass.

I don’t know what to say other than I can only assume you built against my supplied x86 libs which I should have not included?

You’ve assumed right :wink: I did build against your x86 lib. The errors I posted were from building against the “stock” x86 lib included with Cocos2d-x. I did not try your x64 version yet so I don’t know if your version gives me the same problems (I first want to be sure x86 works properly). Does your game actually use libXML2? If not, then most likely it isn’t called and linked (because Cocos2d-x does not call libXML2 anymore as it uses tinyXML) and that perhaps explains why it passes the certification tool without modifications to libXML2.

In the meantime I’ve deleted the final “illegal” call in the libxml2 sources and now have a X86 version that (1) works with the libXML2 calls in my App and (2) does not fail the certification tool. Now I just have to figure out how to get an ARM and X64 version from the libXML2 makefiles.

Would be awesome if you could follow the steps using the 64 bit libs. To be honest there maybe more to the steps I posted above…ie, commentting cocos2dx calls relying on missing lib functions.

My goal was to get a certified app and these steps were created from my recollection of the steps I took to get there.

I tried to follow the X64 steps. The compile seems to go ok; but linking gives me the same problem:

libxml2.lib : error LNK2001: unresolved external symbol snprintf

Could you let me know how you compiled libXML2 for X64 and ARM? I’ve got the modified sources and they work for X86, but I have no clue as how to compile them for a different platform.

Got a x64 version of libXML2 .My App compiles and links without error, but is does not deploy (I think it is because I’ve a32bit version of Win8 in my VM). So only the ARM challenge is remaining.

When trying to compile the libXML2 sources for ARM, I get the following error:

compiling desktop applications for the arm platform is not supported

Any ideas?

The ARM version in your zip gave me also the same error:
libxml2.lib : error LNK2001: unresolved external symbol snprintf

I’ve managed to compile one on my own based on the libXML2 sources I modified (I had to modify crtdef.h to get it to compile without errors for ARM). My App now compiles and links without errors.

So I now have functioning and WACK passing x86, x64 and ARM version of the libXML2 static library. I have absolutely no idea wether my apps actually works on X64 or ARM, but at least they are build without errors for those platforms now. Thanks for the howto and if you need my versions of the static libs, just let me know

You should just create a git pull for this repository on github.

Amazing work Trent, thanks!

Confirming it all seems to work testing on my WinRT ARM tablet.

Any chance that libxml2 version without snprintf for ARM could be placed somewhere? I’m going to try and compile the version with the crtdef changes, but if there is a version lying around it would be very helpful. Thanks!

Jeff Rosko wrote:

Any chance that libxml2 version without snprintf for ARM could be placed somewhere? I’m going to try and compile the version with the crtdef changes, but if there is a version lying around it would be very helpful. Thanks!

My App is live for all three build configs (ARM, X64 and X32). I’ll see if I can find the libs and provide you with a link.

Jeff Rosko wrote:

Any chance that libxml2 version without snprintf for ARM could be placed somewhere? I’m going to try and compile the version with the crtdef changes, but if there is a version lying around it would be very helpful. Thanks!

And here they are: http://knippie.com/libraries.zip

Awesome, thanks! I have it up and running on my surface tablet as we speak :slight_smile:

Now to make sure it validates.

Jeff Rosko wrote:

Awesome, thanks! I have it up and running on my surface tablet as we speak :slight_smile:
>
Now to make sure it validates.

Great. It should validate without problems. My app uses these libs and is live in the store.