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

Search This thread

chinabull

Senior Member
Aug 10, 2009
82
66
ottawa
www.zibotronix.com
Not sure it matters but just want to confirm the vs 2012 express also has the arm compiler included. I have built and run one of our win32 app on my vivotab rt. Of course I have to do the trick for vs 2012 settings and pulled libs from my rt tablet. I have 3 versions of vs 2012 express installed: WP, windows8, windows desktop, btw.

Sent from my RM-820_nam_canada_200 using XDA Windows Phone 7 App
 

chinabull

Senior Member
Aug 10, 2009
82
66
ottawa
www.zibotronix.com
You have mentioned in the first post:
"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."

I tried to add a .S file into the project and the visual studio 2012 express doesn't even want to compile it.

Has anybody actually tried a quick assembly file test? Do I have to get the VS2012 Pro edition?

Thanks.

The file I have used:

test.S:

AREA my_test, CODE, READONLY ; name this block of code
EXPORT test

test proc ; start of a procedure
ldr r0,[r15]
mov pc,lr
endp ; end of a procedure

end ; end of the file

---------- Post added at 02:57 PM ---------- Previous post was at 02:19 PM ----------

I have found a way around it.
1. use the armasm.exe included in the VC express to manually compile the .S into .obj
2. include the .obj into the VS express' project
3. rebuild

Still, it'll be really nice to be able to do it automatically in the VS IDE.
If anybody find any way to achieve it, please let me know.
 

bfosterjr

Senior Member
Jan 13, 2013
167
192
Still, it'll be really nice to be able to do it automatically in the VS IDE.
If anybody find any way to achieve it, please let me know.

Add the .s file to the project then open its properties...

General->ItemType ... change this to Custom Build Tool.. and hit apply.

You can then specify a command line for which to build the file using armasm.exe

Cheers!
 

bfosterjr

Senior Member
Jan 13, 2013
167
192
8.1 Preview

All,

FWIW, the 8.1 preview SDK and WDK have full arm support and tools - desktop apps and drivers.

Just mentioning it here for people that might not have already discovered this.

I haven't yet used any of te included libraries yet, but will give them a shot soon

Cheers!
 
Dumbin missing

i'm running it in my development machine with visual studio 2012 installed, Any idea ?
It sounds like dumpbin is not on your path. Navigate to Programs -> Visual Studio -> Tools, and then set the appropriate environment (it puts the tools on path).

---------- Post added at 11:10 PM ---------- Previous post was at 10:59 PM ----------

Thanks. Also, one more question. As you may already know a person can build there own arm base device to test code on. I wish to do this for the rt. Is there a list of requirements for building for rt. ( the device could be made with Adriano and arm. How do a attain a development copy of rt or rt embedded?
Try Windows 8 Embedded.

http://www.itpro.co.uk/operating-sy...dded-8-now-available-through-volume-licensing

Windows Embedded 8 is now available for enterprise customers to buy directly from Microsoft through its volume licensing programme for the first time.

The offering is designed to extend the Windows 8 experience to a wide range of edge devices and make it easier and more secure for them to exchange data with an organisation’s back-end systems.

The software giant claims the operating system can support industry-specific devices, including medical devices, self-service kiosks and digital signage units.

...
 

chinabull

Senior Member
Aug 10, 2009
82
66
ottawa
www.zibotronix.com
Are you talking about the express version of the VS or professional/ultimate version?
Please clarify.

Thanks.

All,

FWIW, the 8.1 preview SDK and WDK have full arm support and tools - desktop apps and drivers.

Just mentioning it here for people that might not have already discovered this.

I haven't yet used any of te included libraries yet, but will give them a shot soon

Cheers!
 

chinabull

Senior Member
Aug 10, 2009
82
66
ottawa
www.zibotronix.com
I don't know if it's because of the windows phone SDK I installed or not, my visual studio 2012 express has Arm tools and I can build windows desktop app for my tf600 windows rt tablet.
That is why I am asking about if 2013 express has arm tools.


Sent from my RM-820_nam_canada_200 using XDA Windows Phone 7 App
 

screamer333

Member
Feb 14, 2007
35
0
sorry guys, maybe wrong topic for this question,
but, is there are a chance that ported WM5/6 arm app could be run on RT?
 

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
Architecture difference shouldn't be *too* big a problem unless they were using assembly or something crazy like that, but it may make porting require a bit more futzing with the compile options. The difference between the CE and NT versions of the WIn32 API are almost certain to be a bigger problem. It's possible to code portably between those OSes - I know somebody who had an app that could be compiled fro both WinMo and x86 desktop Windows from the same source code - but it's likely something that not many people bothered to do.
 

CraigHumphrey

Member
Jan 18, 2005
14
0
Auckland, New Zealand
VS 2013 Preview works as well

Hey People,

just tried the Platform.Common.Props hack on VS 2013 Ultimate Preview (v12.0.20617.1) and it works a treat, though you have to modify the file in the C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\ARM folder instead. (note: the V120, not V110).

Later'ish
Craig
 

Myriachan

Senior Member
Feb 11, 2013
117
175
Hey People,

just tried the Platform.Common.Props hack on VS 2013 Ultimate Preview (v12.0.20617.1) and it works a treat, though you have to modify the file in the C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\ARM folder instead. (note: the V120, not V110).

Later'ish
Craig

There's no need to modify the VS2013 installation at all if you edit your project files in Notepad: http://xdaforums.com/showpost.php?p=39230921&postcount=48

This is better because you can just distribute your project files to others, rather than rely upon them hacking their local VS installation as well.
 

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
For bonus points, I'm pretty sure there's a template somewhere which can be modified so that the edit is present in all your new projects by default...
 

Đonny

Member
Mar 28, 2009
5
0
Driver / Keyboard layout

Hey guys, really great job with this and with jail-breaking WinRT!
Has anybody managed to build a driver successfully.
I'm trying to build a keyboard layout. It's really not a driver but from compilation point of view it sorta is.
When I try to build from Visual Studio I get
Code:
The target "Build" does not exist in the project
(the same project builds on x86).
When I try to build from command line (to avoid MSBuild) I'm getting a lot of errors like these:
Code:
C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h(7736) : error C4013: 'ReadAcquire8' undefined; assuming extern returning int
or
Code:
C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h(7999) : error C4013: 'WriteNoFence64' undefined; assuming exte
C:\Program Files (x86)\Windows Kits\8.0\include\um\winnt.h(18832) : error C2065: 'CP15_TPIDRURW' : undeclared identifier
r
But I'm not sure I my command line for CL is good. I took x86 command line from Visual Studio and replaced a few stuff.
Code:
cl /GS /analyze- /W4 /Zc:wchar_t- /I"obj\Win32\Win8 Debug" /I"..\..\inc" /Zi /Gm- /Od /FI"C:\Program Files (x86)\Windows Kits\8.0\Include\Shared\warning.h" /fp:precise /D "_X86_=1" /D "i386=1" /D "STD_CALL" /D "WIN32_LEAN_AND_MEAN=1" /D "_WIN32_WINNT=0x0602" /D "WINVER=0x0602" /D "WINNT=1" /D "NTDDI_VERSION=0x06020000" /D "DBG=1" /D "_WINDLL" /errorReport:prompt /WX /Zc:forScope /RTC1 /Oy- /MDd /Fa"obj\Win32\Win8 Debug" /nologo /Fo"obj\Win32\Win8 Debug" /Fp"obj\Win32\Win8 Debug\CzRuQYNm.pch" CzRuQYNm.C CzRuQYNm.DEF

The DLL which represents keyboard layout is actually very simple - it just exports one function which returns a structure. So, it may be possible to compile it against some fake H files with a lot of stuff removed. I really don't need any "ReadAcquire8".

I'd appreciate any hint how to proceed, or if somebody managed to build keyboard layout successfully and can provide some guidance, it'd be great.
I'm attaching a project I'm trying to build.
 

Attachments

  • kbd.rar
    12.3 KB · Views: 29

mamaich

Retired Recognized Developer
Apr 29, 2004
1,150
228
mamaich-eng.blogspot.ru
I've successfully built test drivers for RT, but only from GUI.
I have not looked into your code, but my guess is that you are trying to use the API that is not present on RT. MS have removed lots of obsolete kernel APIs in RT.
 

bfosterjr

Senior Member
Jan 13, 2013
167
192
Hey guys, really great job with this and with jail-breaking WinRT!
Has anybody managed to build a driver successfully.

Yes, several.

They will build fine in visual studio so long as you build it as a native dll, specify the driver switch, and set the entry point. Generating an ntoskrnl and Hal lib on your own is very tricky and you'll have some linker errors - they can be fixed... But its not trivial. The best thing to do is to grab the kernel libs from the latest vs2013 preview sdk and link against those libs. Avoids a lot of headaches.

If you have a look at the pdb I released for kprocesshacker you'll see the complete build strings I used for building the driver. That should help you out with any other missing cl & link switches. I intentionally posted that pdb so people could sort out kernel build issues.

Debugging a driver is another matter entirely! Crash dumps are your friend! :)

Cheers!
 

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
@donny: This is *NOT* the thread for discussing kernel driver development! Right forum, though. I strongly recommend starting a new thread for your project.

With that said, I can tell you at least one completely obvious problem: you're explicitly defining the preprocessor macros _X86_ and i386. Those are (as the names suggest) used to indicate compilation of x86 code. RT runs on ARM processors (using the THUMB2 instruction set, but Microsoft just uses calls it ARM and ignores the non-THUMB2 instruction sets that ARM supports). In any case, you shouldn't need to explicitly define those macros anyhow; the compiler does that for you! Unlike some compilers, MSVC doesn't use the same program to compile for different architectures. When you look at the Visual Studio 2012 Command Line shortcuts, you'll note that there are at least three - x86, amd64/x64, and ARM. Each one sets up the environment for a different compilation target, including ensuring you'll get the right program when you invoke the compiler.
 

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.