Skip to content
 

Compiling with Microsoft’s ARM compiler for Windows Mobile with Visual Studio

I have played with Visual Studio 2008 and Microsoft Mobile SDK to build some native code for windows phone. This is pretty much a LOG for myself, since I tend to forget things. Currently I have the Snes9x sources compiled inside a native COM DLL, which I can use from the managed wp7 code. Don’t get too excited since that code probably don’t work at all (yet), but it’s a nice start, and I like to learn how to use new tools by using them.
I started by building the snes9x sources as a one static library, and including that library from a COM DLL, which will define the interface the to managed code. It’s a nice way to build an app, since I can easily separate the COM communication interface and the snes9x code.

The Environment

You can not actually build a native library with Windows Phone SDK, but it seems that you can build a COM DLL with Windows Mobile SDK, and use that from the managed code. This is totally unsupported “feature”,  so everything might not work as you expect 😉
First you must install Visual Studio 2008 and Windows Mobile SDK. You can get more details of the native environment from Heathcliff74 XDA-developers post
I installed the good old Windows XP inside a virtual box, and then I installed

  1. Visual Studio 2008 with latest service pack and hotfixes.
  2. Windows Mobile 6 Professional SDK Refresh.
After everything has been installed we can start the development by creating a new static library.

Creating a static library

To create a static library you should create a new project (file/new project). Choose Visual c++ / Smart Device / Win32 Smart Device Project. Then choose Application settings, and choose application type, and use “static library”

Precompiler settings

You can find the Precompiler settings in Visual studio under project/settings/c/c++/Preprocessor tab.

project/settings/c/c

Precompiled headers

I had not used the precompiled headers before, so this was a new feature for me. I recommend reading Wikipedia’s Precompiled header article for more details how it works etc. Precompiled header is basically a big header file compiled from multiple header files. It’s a nice idea, and it could reduce the build time, but sadly it seems to totally mess up my static lib project, so I decided to live without it.
The precompiled header can be turned on/off under  project/settings/c/c++/Precompiled Headers

Creating a COM DLL

To create a COM DLL you should create a new project (file/new project). Choose Visual c++ / Smart Device / ALT Smart Device project. Then choose Dynamic Link Library under application settings.

Including a static library

First you must add a reference into you project ( the COM project in my case). Right click the project, and choose “References..”. And the next dialog you can click “Add Reference” and add your new static library project as a reference.
Next add the static library as a project dependency by right clicking the project and choose “project dependencies” and you can choose the new static libraries as dependencies to your project.

project references

Adding Include Dirs

You can add Include Dirs into the project under project/settings/c/c++/General

Building the COM DLL

After I have added the static libs, and the proper include directories (pointing at the static libs) I can successfully build the project. I decided to use the “precompiled headers” with my COM library, since it’s not breaking anything.

Next steps

I’ll probably start playing with the COM interface, and see what I can do with this code. It’s still quite possible that everything is totally broken, and I didn’t accomplish anything, but it was still nice to play with new tools etc.

8 Comments

  1. sq says:

    did you unlock your lumia yet?

    • Summeli says:

      I have the devcert from microsoft, so I can install whatever I want into my own phone 😉

      • sq says:

        URGH I HATE EVERY FIBER OF YOUR DEVELOPERS’ PRIVILEGE YOU OPPRESSIVE HETERONORMATIVE PATRIARCH
        jokes aside, you know that i’m at your service if you ever need some help with graphics and such. i don’t own a winphone myself but i’ve played quite a bit with silverlight
        have you seen the nes emulators currently available? apparently managed code is enough for emulating such small systems

        • Summeli says:

          Managed code is enough for small system, but we could have so much more with the native code. I’m sure that Microsoft will release the native SDK eventually (as Google did with Android). Safest bet would be to say that the native is coming with Windows Phone 8 & WinRT, but I’m hoping that they would release it sooner.
          I’m really far away from needing any graphics at this point. I still have lots of work to do before I even know that does the snes9x stuff even work 🙂

  2. SamTheMan says:

    Can you get application using native library published to Windows Phone Marketplace?

  3. dave says:

    hi summeli.. i am very impressed with your coding works etc just have one question if you wouldnt mind…
    iv looked into your psx4all source and was wondering… how the heck do i transfer all that stuff into a qt symbian app haha.
    realy would like to continue the development possibilities on the nokia n8 it has such promise..
    look forward to your reply
    cheers
    Dave

  4. rutwick says:

    please add cheat option in gpsp…has the development stoped for gpsp?

Leave a Reply

(required)