[how to] compile and port win32 apps to Windows RT ARM

Search This thread

DarkoLord

Member
Jul 29, 2008
44
17
Is there a way you can link DRV files?

I use the the excellent dll-to-lib.ps1 script it makes a .lib file and I can link it, however the compiled application then wants the DLL file - copying the .drv file to the application folder and renaming it to .dll does work, however it seems a bit redundant...

It's the same with OCX files...
 

stephensteck

New member
Aug 21, 2009
3
0
Remote Debugging

I have gotten my application to load on the Surface RT, but it seems to hang at a certain point. Is there any way to set up remote debugging (the application runs fine on the x86 or x64 platforms) so I can figure out where it is hanging?
 

DarkoLord

Member
Jul 29, 2008
44
17
Yes, of course. You can install the remote debugger (get it here or in the VS install dir) on the RT and connect to it with your desktop VS.
 

Myriachan

Senior Member
Feb 11, 2013
117
175
I figured out a way to support RT desktop compilation without modifying the compiler's Microsoft.Cpp.ARM.Common.props file, which is nice if you want to distribute your changes to others.

Set up each of your Visual Studio projects to have an ARM target as usual, then close Visual Studio. For each .vcproj file of the solution, do the following:

1. Open the .vcproj file in Notepad or a similar text editor.
2. Find the <PropertyGroup> tag representing the Debug ARM target. An example:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
3. Inside that PropertyGroup, add this tag:
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
4. Repeat for any other ARM targets you have (typically Release).

That tag is the same as the one you can add to Microsoft.Cpp.ARM.Common.props, but without having to modify your Visual Studio installation. For the extra .lib files, you can always just put them in one of your project directories and add that directory to your library path for the project. Then no changes to Visual Studio 2012 will be required to compile your project.
 

YamiHoshi

Senior Member
Nov 28, 2009
57
8
Breda
Hi there,

I've almost fully ported an App I always preferred to be Ported.
However, it uses DirectX 8, and I'm getting this error:
Code:
error LNK2001: unresolved external symbol Direct3DCreate8

Anybody who can help this girl out again?
 

netham45

Inactive Recognized Developer
Jun 24, 2009
886
569
Denver
Hi there,

I've almost fully ported an App I always preferred to be Ported.
However, it uses DirectX 8, and I'm getting this error:
Code:
error LNK2001: unresolved external symbol Direct3DCreate8

Anybody who can help this girl out again?

DirectX 8 isn't present on the tablet, you can either port it to render in software mode or port it to one of the versions of DirectX that is present (I want to say DX9/10/11 are present, but in limited forms, but I'm honestly not sure.)
 

Myriachan

Senior Member
Feb 11, 2013
117
175
Hi there,

I've almost fully ported an App I always preferred to be Ported.
However, it uses DirectX 8, and I'm getting this error:
Code:
error LNK2001: unresolved external symbol Direct3DCreate8

Anybody who can help this girl out again?

Hi =^-^= Glad I'm not the only girl here. =)

I'd just port it to DirectX 9. I once ported a professional AAA-title Windows game from DirectX 8 to DirectX 9 in about 3 hours. They are really, really similar interfaces.

Do the porting to DirectX 9 on x86 first, then port over to ARM. It'll be easier that way.
 

YamiHoshi

Senior Member
Nov 28, 2009
57
8
Breda
Porting to DirectX 9 worked, but there's another problem incoming: AVIFIL32.dll is missing.
It's present on my Windows 8 PC, but it doesn't work on the Surface.
 

lilstevie

Senior Recognized Developer
Apr 17, 2009
1,339
1,040
Porting to DirectX 9 worked, but there's another problem incoming: AVIFIL32.dll is missing.
It's present on my Windows 8 PC, but it doesn't work on the Surface.

if it isn't present in the windows rt system that may be a little bit of an issue. does it provide important functionality for the application?
 

YamiHoshi

Senior Member
Nov 28, 2009
57
8
Breda
Yes, even a lot, as it's a recording App.
The Source Code I've got still uses VFW, which is a really, really old API.
The original maker of it has already rewritten it to the new one, I'll try to get my brother to ask for the new Code.
 

SixSixSevenSeven

Senior Member
Dec 26, 2012
1,617
318
Hi =^-^= Glad I'm not the only girl here. =)

I'd just port it to DirectX 9. I once ported a professional AAA-title Windows game from DirectX 8 to DirectX 9 in about 3 hours. They are really, really similar interfaces.

Do the porting to DirectX 9 on x86 first, then port over to ARM. It'll be easier that way.

thats great but we dont have directX 9 either. 9 and 10 are next to non existant on RT. 11 is there I think.
 

netham45

Inactive Recognized Developer
Jun 24, 2009
886
569
Denver
Porting to DirectX 9 worked, but there's another problem incoming: AVIFIL32.dll is missing.
It's present on my Windows 8 PC, but it doesn't work on the Surface.

I wasn't able to find it when I ported over WabbitEmu (has a recording feature), but since it wasn't critical to the app's core functionality I just removed it.
 

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
AVI is just a media file container, not an actual codec. Depending on the necessary codec support and the complexity of the API, it may be possible to either implement it yourself or adapt one of the open-source implementations.

Alternatively, you may be able to just rip out AVI support. Nobody sane will mind that much; it's a deprecated and mildly terrible format.
 

mamaich

Retired Recognized Developer
Apr 29, 2004
1,150
228
mamaich-eng.blogspot.ru
Updated the windows RT MFC library. Download it here: https://drive.google.com/folderview?id=0B25hIeyRmniUZzk0c3hNZmVDSms&usp=sharing
Now you can use MFC controls in dialog templates, COM maybe working, and non-unicode library is present (non-unicode lib is only release build, as debug build fails to run for some reason).
MFC sources with my modifications are attached, so anyone can rebuild them if needed.

Edited 29 apr.
Archive mfc-winrt.7z on google drive contained a wrong uafxcw.lib file - the apps using that lib would not build. Reuploaded a correct archive.
 

Attachments

  • atlmfc-winrt-src.7z
    2.5 MB · Views: 1,024
Last edited:
  • Like
Reactions: pcm2008

mamaich

Retired Recognized Developer
Apr 29, 2004
1,150
228
mamaich-eng.blogspot.ru
Reposting here to keep all porting hints in the same thread.

danesh110 found that beta version of Visual Studio 2012 (VS11) contained the ARM MFC library: http://xdaforums.com/showpost.php?p=40988765&postcount=690
VS11 beta contains both static and DLL MFC versions, both debug and retail. You can download it here: http://download.microsoft.com/downl...-40C9-A53C-E6322E2F033D/VS11_BETA_ULT_ENU.iso, install it, for example, into virtual machine and grab files from "C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\lib\arm" folder.

It is better to use Microsoft-made MFC than my files - as my sources contain some stubs and hacks.
I've compared the MFC sources from VS11 beta with the retail VS2012 - they are more complete in beta. Sources contain files missing from the retail build.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 16
    Here's a basic guide on how to port, since some people were asking:

    Prerequisites:

    Windows 8 (non-RT) development machine

    Visual Studio 2012 (Don't know if express will work, but evaluation editions exist here: http://www.microsoft.com/visualstudio/eng/downloads)

    dll-to-lib tool (http://xdaforums.com/showthread.php?p=36597774)

    Part 1: Getting necessary libs:

    (1) On your Windows RT device, copy the .dll files in C:\Windows\System32 to some directory on your development machine (We'll call it C:\rtdev\dlls).

    (2) Create a directory on your development machine for the libs (we'll call it C:\rtdev\libs)

    (3) Extract the dll-to-lib to your lib directory

    (4) Open powershell (run powershell.exe) and navigate to the libs directory

    (5) run the lib script against the dlls ("./dll-to-lib.ps1 C:\rtdev\dlls).

    (6) If you've never run a powershell script before, you might get a signing error. You can type "Set-ExecutionPolicy Unrestricted" to run the script. Please be aware of the security implications if you choose to do this.

    (7) You now have a bunch of libs that tell the linker what functions are available in the DLLs on the Windows RT device. Copy the libs that you need to "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\arm". DO NOT OVERWRITE ANY EXISITNG LIBS (repeat: DO NOT OVERWRITE ANY EXISITNG LIBS OR YOU MAY HAVE TO REPAIR/REINSTALL VS) You'll probably have to change the security permissions if you want to copy to this directory, or copy as an administrator.

    Part 2: Fixing the compiler.

    The compiler won't let you build desktop apps due to a configuration setting. Fortunately, some people at stack overflow figured this out:
    http://stackoverflow.com/questions/11151474/can-arm-desktop-programs-be-built-using-visual-studio-2012

    Basically, edit:
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\ARM\Microsoft.Cpp.ARM.Common.props

    to include:
    <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
    before </PropertyGroup>

    Part 3: Building a Win32 Hello World app.

    Now that we have the libs out of the way, lets build a basic hello world app.

    (1) Start Visual Studio 2012.

    (2) Create a new project, select Visual C++ (might be under other languages) and pick Win32 Project.

    (3) In the wizard, select "Console Application", and press "Finish".

    (4) Replace the program body with some text that prints hello world:

    #include "stdafx.h"
    #include <stdio.h>

    int _tmain(int argc, _TCHAR* argv[])
    {
    printf("Hello World!");
    return 0;
    }

    (5) Add the ARM configuration settings in configuration manager. Goto Build>Configuration Manager, and under "Active Solution Platform" click on Win32 and click New. Select "ARM" under "Type or select the new platform", and press "OK".

    (6) Select the "Release" configuration and build the solution (F6). With some luck, some win32 ARM binaries should appear in the ARM subdirectory of your project.

    Part 4: Porting Apps

    Now that your compiler works, you can port apps over. Most apps that have a VC++ project should port fine just by adding the ARM configuration.

    Some apps will have manually set \MACHINE:x86, in which case you will have to change that in the linker options. Also, ARM doesn't support no dynamic rebase, so if you get that error, turn of \DYNAMICBASE:NO in the linker options.

    A lot of cross-platform apps will use 'nmake' or the like. For the most part, these apps can be cross compiled using the VS 2012 ARM Cross Tools - you can find that in your start menu- In Windows 8 just type "ARM" and it should show up.

    Also some interesting issues might experience:

    You might encounter missing symbols from __imp_XXXX or the like from the linker. If it looks like a Win32 function, you just need to explicitly add the .lib (in project properties under Linker->Input->Additional Dependencies, type the name of the lib, which you need to also copy to the VC\lib\arm directory as above. Some common libs include "gdi32.lib" "shell32.lib" and "ole32.lib". You can usually find the .lib under the msdn references: for example this entry for GetUserName http://msdn.microsoft.com/en-us/library/windows/desktop/ms724432(v=vs.85).aspx tells us we can find GetUserName in Advapi32.lib. Also the A and W suffixes just represent the ANSI and unicode version of these functions.

    When compiling big libraries like Qt, you might run into some problem about BLX fixups, since relative jumps on arm are limited (23 bits?) I guess they didn't create fixup islands in the MSVC compiler, but I found if you set \INCREMENTAL:NO, that should fix the problem most of the time. Otherwise you might have to add an \ORDER file and manually order things. See stack overflow topic for more details: http://stackoverflow.com/questions/11478055/lnk2013-error-fixup-overflow

    Another serious pitfall.. no in-line assembly support in the MS ARM compiler. So you'll have to write in your assembly in a .S file and link to it.

    ...hopefully this helps someone - happy coding!
    6
    I figured out a way to support RT desktop compilation without modifying the compiler's Microsoft.Cpp.ARM.Common.props file, which is nice if you want to distribute your changes to others.

    Set up each of your Visual Studio projects to have an ARM target as usual, then close Visual Studio. For each .vcproj file of the solution, do the following:

    1. Open the .vcproj file in Notepad or a similar text editor.
    2. Find the <PropertyGroup> tag representing the Debug ARM target. An example:
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    3. Inside that PropertyGroup, add this tag:
    <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
    4. Repeat for any other ARM targets you have (typically Release).

    That tag is the same as the one you can add to Microsoft.Cpp.ARM.Common.props, but without having to modify your Visual Studio installation. For the extra .lib files, you can always just put them in one of your project directories and add that directory to your library path for the project. Then no changes to Visual Studio 2012 will be required to compile your project.
    2
    A lot of cross-platform apps will use 'nmake' or the like. For the most part, these apps can be cross compiled using the VS 2012 ARM Cross Tools - you can find that in your start menu- In Windows 8 just type "ARM" and it should show up.

    I have found with some nmake projects you need to add
    Code:
    /D _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
    to your CFLAGS otherwise cl complains about not being able to build desktop arm executables even with the change made to visual studio
    2
    Did you manage to run anything in 2017? Please reply even if you didn't

    You can only build with VS2012
    2
    Reposting here to keep all porting hints in the same thread.

    danesh110 found that beta version of Visual Studio 2012 (VS11) contained the ARM MFC library: http://xdaforums.com/showpost.php?p=40988765&postcount=690
    VS11 beta contains both static and DLL MFC versions, both debug and retail. You can download it here: http://download.microsoft.com/downl...-40C9-A53C-E6322E2F033D/VS11_BETA_ULT_ENU.iso, install it, for example, into virtual machine and grab files from "C:\Program Files\Microsoft Visual Studio 11.0\VC\atlmfc\lib\arm" folder.

    It is better to use Microsoft-made MFC than my files - as my sources contain some stubs and hacks.
    I've compared the MFC sources from VS11 beta with the retail VS2012 - they are more complete in beta. Sources contain files missing from the retail build.