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

Search This thread

lilstevie

Senior Recognized Developer
Apr 17, 2009
1,339
1,040
As i said earlier, there is no Arm option under Active Solution Platform > new. any idea ?

1Tr57.png

You are in the manager for .net there, which is CLR and does not need to be set to arm
 

lilstevie

Senior Recognized Developer
Apr 17, 2009
1,339
1,040
are you willing to explain about that ?, where do i know my application can be used on windows RT ?, thanks

.net applications are platform independent as they are built on a common language runtime (CLR) which is interpreted at runtime and converted into machine code.

Silverlight apps are also CLR but they will not run on Windows RT due to it not being present.

It is fairly difficult to "guess" which of the CLR types you are trying to compile without knowing more about the project, but if it is .net converting it to pure .net 4.5 should be enough providing it isn't WPF.

Where the ARM libs and compiler come in is for C/C++ projects as these turn out native executables.
 
  • Like
Reactions: rheza02

rheza02

Senior Member
May 20, 2006
481
12
.net applications are platform independent as they are built on a common language runtime (CLR) which is interpreted at runtime and converted into machine code.

Silverlight apps are also CLR but they will not run on Windows RT due to it not being present.

It is fairly difficult to "guess" which of the CLR types you are trying to compile without knowing more about the project, but if it is .net converting it to pure .net 4.5 should be enough providing it isn't WPF.

Where the ARM libs and compiler come in is for C/C++ projects as these turn out native executables.

I just created a new project Windows Forms Application, and guess what, I'm able to run it on windows rt. unfortunately i have been working this two days on WPF project. what a waste. is there any workaround to compile WPF project for Windows RT ?

Thanks lilstevie.
 
Last edited:

xsoliman3

Senior Member
Jan 25, 2012
113
34
I'm getting the following when compliling (linking) arm console and gui apps
>msvcrt.lib(wcrtexe.obj) : error LNK2001: unresolved external symbol __imp_EncodePointer

Tried adding msvcrt.lib into configuration, Linker, Input, Additional Dependancies -- no help
(update - and kernel32.lib is already in there)

msvcrt.lib was already in the lib\arm\ directory and I didn't overwrite it

Update
My cmd line building of cmd line apps (using /D _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE) that used to work, has also stopped working
(cmd line building of gui apps always gave me issues with lib's etc and I'm still working on that)

Taking the new lib's out of ..\lib\arm and the build from cmd line works again

Looks like I got some lib in there that adversely affects both cmd line and VS gui builds

Now fixed (cant remember exactly what new lib I had to remove, it was in amongst all the l*.lib and m*.lib ones)

Update3
If VS fails at the link stage with "incorrect MSPDB110.DLL version", just temporarily delete (rename) the MSPDB110.DLL in the bin\x86_arm directory
 
Last edited:
Feb 13, 2007
32
3
Atlanta
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?

Sent from my SGH-T999 using xda premium
 

netham45

Inactive Recognized Developer
Jun 24, 2009
886
569
Denver
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?

Sent from my SGH-T999 using xda premium

RT is only available on OEM devices (retail tablets, Surface, Vivo Tab, etc...)
 

netham45

Inactive Recognized Developer
Jun 24, 2009
886
569
Denver
According to http://msdn.microsoft.com/en-us/library/bb432254(VS.85).aspx, EncodePointer is in kernel32.lib. Typically this library is included by default, I believe, but for ARM projects it must be added manually under Project Properties -> Linker -> Input.

In the future, when you encounter such messages, just go look on MSDN for the .LIB that you need to use.

You could also be lazy and put all of your Windows RT libs in a folder and just add 'c:\path\to\folder\*.lib' as a library and it'll import all of them. That's what I've been doing.
 

bartekxyz

Senior Member
Aug 15, 2011
56
50
Hi, I'm trying to recompile ScummVM for Windows RT and everything seems to go well, after changing solution platform and configuration building goes well, but at 99% there is an error:

Code:
Error	2	error MSB6006: "cmd.exe" exited with code 9009.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets	172	5	scummvm

Could anyone help?

EDIT: Possibly I found source of a problem:

Code:
31>------ Rebuild All started: Project: scummvm, Configuration: Release ARM ------
31>  Performing Custom Build Tools
31>  'nasm.exe' is not recognized as an internal or external command,
31>  operable program or batch file.
31>  Performing Custom Build Tools
31>  'nasm.exe' is not recognized as an internal or external command,
31>  operable program or batch file.
31>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(172,5): error MSB6006: "cmd.exe" exited with code 9009.
========== Rebuild All: 30 succeeded, 1 failed, 0 skipped ==========

From ScummVM dev wiki:

"Additional tools

You will need to download and install nasm which is used for assembler versions of our scalers."

Must find a way to cut it from source.

EDIT: Ok, there were 2 scalers written in ASM, I deleted those so nasm is no longer needed, also scummvm make use of libmad - MPEG audio decoder library which has some inline assembly so I was forced to get rid of it. Still there are 6 errors I can't resolve:

Code:
31>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(1182): warning C4005: 'ARRAYSIZE' : macro redefinition
31>          ..\..\common/util.h(58) : see previous definition of 'ARRAYSIZE'
31>D:\Programy\VS2011\VC\include\setjmp.h(122): warning C4005: 'setjmp' : macro redefinition
31>          ..\..\common/forbidden.h(189) : see previous definition of 'setjmp'
31>D:\Programy\VS2011\VC\include\setjmp.h(175): error C2146: syntax error : missing ';' before identifier 'SYMBOL'
31>D:\Programy\VS2011\VC\include\setjmp.h(175): warning C4229: anachronism used : modifiers on data are ignored
31>D:\Programy\VS2011\VC\include\setjmp.h(175): error C2182: 'FORBIDDEN_look_at_common_forbidden_h_for_more_info' : illegal use of type 'void'
31>D:\Programy\VS2011\VC\include\setjmp.h(175): error C2495: 'FORBIDDEN_look_at_common_forbidden_h_for_more_info' : '__declspec(noreturn)' can only be applied to function declarations or definitions
31>D:\Programy\VS2011\VC\include\setjmp.h(175): error C2143: syntax error : missing ';' before '!'
31>D:\Programy\VS2011\VC\include\setjmp.h(175): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
31>D:\Programy\VS2011\VC\include\setjmp.h(175): error C2059: syntax error : '%'
 
Last edited:

schettj

Senior Member
Nov 17, 2006
655
56
Hi, I'm trying to recompile ScummVM for Windows RT

'FORBIDDEN_look_at_common_forbidden_h_for_more_info'

Have you looked at common_forbidden.h for more info?

These errors usually happen when some header file has ifdef blocks for x86 and x64 and an a final else block that errors. When you compile for arm, you hit that else block. You'll need to figure out the "right" way to do whatever they're doing for arm.

setjump/longjump usually do crap with the pc and stack pointers, so it will be cpu specific. google for arm setjmp.h to get some ideas of what you'll have to do to make it work for arm...
 

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
Also, unless those assembly files were merely optional optimizations for C/C++ code that you can use instead, simply "removing" chunks of assembly is likely to break things. You havne't gotten to the linker, yet; it may conlain of missing program entry points when you do unless you have substitutes for those assembly functions.
 

bartekxyz

Senior Member
Aug 15, 2011
56
50
Also, unless those assembly files were merely optional optimizations for C/C++ code that you can use instead, simply "removing" chunks of assembly is likely to break things. You havne't gotten to the linker, yet; it may conlain of missing program entry points when you do unless you have substitutes for those assembly functions.

Those assembly lines were used by two scalers. Also there is nice tool in scummvm source that you can use to customize project, example:

Code:
C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10>create_project.exe ..\.. --ms
vc --disable-nasm --disable-mad --disable-freetype
Enabled engines:

    SCUMM
    v7 & v8 games
    HE71+ games
    AGI
    AGOS
    AGOS 2 games
    CGE
    Cinematique evo 1
    Magic Composer
    Cinematique evo 2
    Dragon History
    Drascula: The Vampire Strikes Back
    Dreamweb
    Gobli*ns
    Groovie
    Hugo Trilogy
    Legend of Kyrandia
    Lands of Lore
    Lure of the Temptress
    MADE
    Mohawk
    Parallaction
    Flight of the Amazon Queen
    SAGA
    IHNM
    SCI
    Beneath a Steel Sky
    Broken Sword
    Broken Sword II
    Teen Agent
    Tinsel
    Toonstruck
    Touche: The Adventures of the Fifth Musketeer
    TsAGE
    Bud Tucker in Double Trouble

Disabled engines:

    Groovie 2 games
    Eye of the Beholder
    The Last Express
    Where in Time is Carmen Sandiego?
    Riven: The Sequel to Myst
    Myst
    SAGA 2 games
    SCI32 games
    Broken Sword 2.5
    TestBed: the Testing framework
    3 Skulls of the Toltecs

Enabled features:

    zlib (compression) support
    Ogg Vorbis support
    FLAC support
    libpng support
    Theora decoding support
    Bink video support
    Scalers
    HQ scalers
    16bit color support
    integrated MT-32 emulator
    Taskbar integration support
    Translation support
    System language detection support

Disabled features:

    libmad (MP3) support
    FreeType support
    IA-32 assembly support
    OpenGL support
    Virtual keyboard support
    Keymapper support

C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10>

Still, those setjmp errors, specifically in line:

Code:
_CRTIMP __declspec(noreturn) void __cdecl longjmp(_In_ jmp_buf _Buf, _In_ int _Value) throw(...);

It's beyond me so I'm forced to give up.
 
scummvm make use of libmad - MPEG audio decoder library which has some inline assembly so I was forced to get rid of it.

libmad builds fine - it just needs to be built with /D FPM_DEFAULT or /D FPM_64BIT instead of any other potential option. scummvm probably has a config.h for libmad that has:

#define FPM_INTEL

in it (or similar in the C/C++ macro list in VS), which causes x86 assembler to be used in the fixed-point routines.
 

bartekxyz

Senior Member
Aug 15, 2011
56
50
libmad builds fine - it just needs to be built with /D FPM_DEFAULT or /D FPM_64BIT instead of any other potential option. scummvm probably has a config.h for libmad that has:

#define FPM_INTEL

in it (or similar in the C/C++ macro list in VS), which causes x86 assembler to be used in the fixed-point routines.


Good to know. BTW, setjmp errors are gone - adding "#define FORBIDDEN_SYMBOL_ALLOW_ALL" at the beginning of backends/saves/windows/windows-saves.cpp solved this problem. Still I was expecting it to be easier job so don't know if I will handle this.

EDIT: Building went ok, now there are errors during code generation. Could anybody look at this?:

Code:
Error	11	error LNK1169: one or more multiply defined symbols found	C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10\Release32\scummvm.exe	1	1	scummvm
Error	9	error LNK2005: "private: __cdecl type_info::type_info(class type_info const &)" (??0type_info@@AAA@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)	C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10\MSVCRT.lib(ti_inst.obj)	scummvm
Error	10	error LNK2005: "private: class type_info & __cdecl type_info::operator=(class type_info const &)" (??4type_info@@AAAAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)	C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10\MSVCRT.lib(ti_inst.obj)	scummvm
Error	8	error LNK2005: free already defined in LIBCMT.lib(free.obj)	C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10\MSVCRT.lib(MSVCR110.dll)	scummvm
Error	7	error LNK2005: malloc already defined in LIBCMT.lib(malloc.obj)	C:\Users\Bartek\Desktop\scummvm-1.5.0\dists\msvc10\MSVCRT.lib(MSVCR110.dll)	scummvm

EDIT2: Already figured it out. So the very first Windows RT build of ScummVM is ready, much still have to be done but that's some start.

http://xdaforums.com/showpost.php?p=37583092&postcount=402
 
Last edited:

mamaich

Retired Recognized Developer
Apr 29, 2004
1,150
228
mamaich-eng.blogspot.ru
There is no MFC library for ARM in Visual Studio, though DLL is present on the device.
We can't use dll2lib to create our own import library from mfc110u.dll as it exports only ordinals, but I was managed to recompile MFC from sources as a static library. As MS provided incomplete sources - some features are not present, for example using OLE controls and MFC controls embedded in dialogs designed in visual studio dialog editor. Creating those controls dynamically would work fine.
More information is here.
LIB sizes are huge (157 Mb debug and 1.2 Gb release builds) as I have not stripped the debug information. Don't be afraid of that - the produced EXE files would be small.
You can recompile MFC yourself like I did, or download LIBs here: http://www.multiupload.nl/FJEYPW5M26
Compressed with 7Zip as it gave the smallest archive size.

For installation - uncompress them into: "\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\lib\arm\" directory, add "#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS" to your stdafx.h and select "use MFC in static library" in your project settings.
 

no2chem

Senior Member
Jul 18, 2007
276
103
There is no MFC library for ARM in Visual Studio, though DLL is present on the device.
We can't use dll2lib to create our own import library from mfc110u.dll as it exports only ordinals, but I was managed to recompile MFC from sources as a static library. As MS provided incomplete sources - some features are not present, for example using OLE controls and MFC controls embedded in dialogs designed in visual studio dialog editor. Creating those controls dynamically would work fine.
More information is here.
LIB sizes are huge (157 Mb debug and 1.2 Gb release builds) as I have not stripped the debug information. Don't be afraid of that - the produced EXE files would be small.
You can recompile MFC yourself like I did, or download LIBs here: http://www.multiupload.nl/FJEYPW5M26
Compressed with 7Zip as it gave the smallest archive size.

For installation - uncompress them into: "\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\lib\arm\" directory, add "#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS" to your stdafx.h and select "use MFC in static library" in your project settings.

Good idea mamaich, I haven't had much time lately, but I was able to get a mfc .def with most of the named ordinals by using libtool and dumpbin with the .pdb in the directory. If dumpbin detects a .pdb file, it uses the pdb hints to generate the .def. Microsoft SymServer has the pdb for arm.

The problem I had is with the mfc static part, maybe you could figure that out and we'll have MFC :)
 

mamaich

Retired Recognized Developer
Apr 29, 2004
1,150
228
mamaich-eng.blogspot.ru
The problem I had is with the mfc static part, maybe you could figure that out and we'll have MFC :)

Unfortunately I don't have time for that - spending all time on the emulator project.
But it should not be too difficult. After looking at static x86 part - you can see the needed files:
Code:
rawdllmainproxy.obj
stdafx.obj
nolib.obj
appmodul.obj
dumpstak.obj
oleexp.obj
sockexp.obj
dllmodul.obj
dllmodulx.obj
All files except for the last one are present. You need to reconstruct the last one manually looking at the dumpbin output. Or maybe we could ask in microsoft forums for this file? :)
 

GoodDayToDie

Inactive Recognized Developer
Jan 20, 2011
6,066
2,933
Seattle
Ugh... working on porting Free Download Manager, and it's demanding MFC and ATL, and in particular nafxcw.lib. I don't know MFC very well at all; not sure what it would take to get that file but without it I'm not able to port the program. I've gotten almost all the components ported, but the actual EXE is MFC based.
 

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.