在 ARM 上支持 Windows 10 个桌面应用程序 - MFC 和 COM 以及 OPOS 工作吗?

Support for Windows 10 desktop applications on ARM - MFC and COM and OPOS work?

我试图了解将 x86 Windows 10 上的 运行s 的 C++ MFC 应用程序移植到配备 Qualcomm Snapdragon 处理器的 ARM Windows 10 设备的障碍。

32位应用程序具有以下特点:

此应用程序在 Visual Studio 2015/2017/2019 目标 x86 和 Windows 10.

下编译良好

我的问题是:使用 Snapdragon 处理器将此应用程序迁移到 ARM Windows10 可能遇到哪些障碍?

第二个问题是什么是合适的低成本 ARM Windows10 设备?惠普、三星和联想的大多数 Windows 10 ARM Snapdragon 设备的价格似乎都在 800 美元以上,我想要价格低于 200 美元的更便宜的东西。

附带问题:Snapdragon 410 处理器是否可以用于初始测试和兼容性检查。我将 Arrow 的 DragonBoard 410C 视为低成本测试平台。 https://www.arrow.com/en/products/dragonboard410c/arrow-development-tools

This DragonBoard™ 410C based on 96Boards™ specification features the Qualcomm® Snapdragon™ 410 processor, a Quad-core ARM® Cortex™ A53 at up to 1.2GHz clock speed per core, capable of 32-bit and 64-bit operation.96Boards is a 32-bit and 64-bit ARM® Open Platform hosted by Linaro™ with the intension to serve the software/ maker and embedded OEM communities. DragonBoard 410C supports Android 5.1, Linux based on Debian and Win10 IoT Core advanced processing power, WLAN, Bluetooth, and GPS, all packed into a board the size of a credit card. It is designed to support feature-rich functionality, including multimedia, with the Qualcomm® Adreno™ 306 GPU, integrated ISP with up to 13 MP camera support, and 1080p HD video playback and capture with H.264 (AVC).

DragonBoard 820C 可能是更合适的测试硬件,因为它更接近大多数 Windows 10 ARM Snapdragon 产品随附的硬件。 https://www.arrow.com/en/products/dragonboard820c/arrow-development-tools

到目前为止我能找到什么

这个发布的问题 似乎与我的问题最接近,但没有真正的答案。接受的答案是“根本没有 x86 Win32 仿真。您需要使用为该平台设计的工具集。”根据以下文章,这似乎是错误的:

Right now, with Windows 10 on ARM laptops, it’s possible to run 32-bit x86 desktop software using emulation, but not dedicated 64-bit software like, say, Adobe’s Premiere Pro video editing app for example.

Emulation for x86 apps makes the rich ecosystem of Win32 apps available on ARM. This provides the user the magical experience of running an existing x86 win32 app without any modifications to the app. The app doesn’t even know that it is running on a Windows on ARM PC, unless it calls specific APIs (IsWoW64Process2)

Windows 10 on ARM is completely different [from Windows/RT]. This is the full Windows desktop experience. Microsoft has created a special emulator layer that allows traditional 32-bit desktop applications to run on ARM processors, so everything should “just work”. Microsoft even showed off a version of Windows 10 Professional on ARM, and said it supports all the usual advanced features you’d find on Windows 10 Professional.

The emulation works completely transparently to both users and the programs they run. It uses the same WOW (Windows on Windows) technology that Windows uses to run 32-bit applications on 64-bit versions of Windows today. However, the x86-to-ARM emulation happens entirely in software.

使用 VS 2017 和软件组件注意事项为 ARM 编译

这篇文章 https://pete.akeo.ie/2017/05/compiling-desktop-arm-applications-with.html 提供了有关使用 Visual Studio 2017 为 ARM 编译桌面应用程序的一些详细信息。

这篇文章,https://support.microsoft.com/en-us/help/4521606/windows-10-arm-based-pc,在关于限制的部分提到:

Drivers for hardware, games and apps will only work if they're designed for a Windows 10 ARM-based PC. For more info, check with the hardware manufacturer or the organization that developed the driver. Drivers are software programs that communicate with hardware devices—they're commonly used for antivirus and antimalware software, printing or PDF software, assistive technologies, CD and DVD utilities, and virtualization software.

If a driver doesn’t work, the app or hardware that relies on it won’t work either (at least not fully). Peripherals and devices only work if the drivers they depend on are built into Windows 10, or if the hardware developer has released ARM64 drivers for the device.

文章同节还说:

64-bit (x64) apps won’t work. You'll need 64-bit (ARM64) apps, 32-bit (ARM32) apps, or 32-bit (x86) apps. You can usually find 32-bit (x86) versions of apps, but some app developers only offer 64-bit (x64) apps.

这是 Microsoft 门户 Windows 10 on ARM 文档,https://docs.microsoft.com/en-us/windows/arm/ 包含指向页面上各种资源的链接以及带有其他文档链接的左侧边栏。

一些注意事项和其他信息

and the answer appears to be there is no ARM version of SQL Express. However there is a comment that says there is an ARM version of SQL Server Compact. SQL Server Compact has been replaced by SQL Server localDB however I'm not sure if there is an ARM version of that or not however it seems to use parts of SQL Server so an ARM version seems doubtful. See https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-ver15

另一方面,微软似乎正在发布 Azure SQL Edge,它在 x64 和 ARM64 上运行 运行。 https://azure.microsoft.com/en-us/services/sql-edge/

Microsoft 的这个开发者分钟视频描述了在 Visual Studio 中启用 ARM64 构建的步骤。 https://www.youtube.com/watch?v=OZtVBDeVqCE&feature=youtu.be and there are also instructions at this link https://blogs.windows.com/windowsdeveloper/2018/11/15/official-support-for-windows-10-on-arm-development/

我可能不得不面对的一个障碍是我 package/distribute 我的软件(基于 MFC)使用“Visual Studio 安装程序项目”扩展来构建“.msi " 安装程序文件。

问题在于该扩展(还)不包含针对 ARM64 系统的选项,因此我不得不推荐使用 x86 版本。

但是,我还没有能够测试这是否有效。该 MSI 文件是否将软件安装在正确的位置? (即,“Program Files (x86)”文件夹的相关“Emulation”等价物。)

还有一个问题是 VC-RunTime Redistributable Package(s) 应该安装:x86 或 ARM64,或两者?

当然,我可以构建并打包我的针对 ARM64 的二进制文件,但是这样就无法让 MSI 文件将其正确安装到 'native'“程序文件”位置。

此 post 涵盖三个相关活动:

  • 使用 Raspberry Pi 4
  • 为 ARM 设备创建低成本 Windows
  • 在该硬件上使用 Windows 10 ARM 测试一个简单的 MFC 应用程序
  • 正在测试使用 Nullsoft 脚本安装系统 (NSIS) 创建 Windows 安装程序

一旦我对更大更复杂的 MFC 应用程序进行了进一步测试,此 post 将更新为包含更多信息。

  • 拉取源代码并为 ARM64 重新编译 OPOS 控制对象
  • 使用 ADO 数据库引擎接口进行测试
  • 使用信号量、临界区和多线程

注意: 因为在我的测试中,我使用的是 Windows 10 ARM 的预览版,Microsoft 在不支持的设备上不支持该版本Microsoft 或其他供应商,我的体验与使用实际 Microsoft 产品可能存在一些差异。

问题是目前 Windows 10 ARM 不像英特尔的 Windows 10 那样作为单独的产品出售。它只是 OEM 产品。我发现在廉价设备上使用 Windows 10 ARM 进行测试的唯一方法是使用 Windows 10 ARM.

预览版的这种方法

Windows ARM 在 Raspberry Pi 4

上的硬件设置

查看 Arm 设备上 Windows 的价格,我发现价格大多在 500 美元以上 运行ge。我确实找到了一个关于微软和高通正在开发的低成本开发平台的公告,即 Snapdragon 开发者套件,但是我找不到它在哪里可用。

所以我继续使用 Windows 10 ARM 在 Raspberry Pi 4 B 上,4GB RAM 和 128 GB SSD,使用 USB 3.0 转 SATA 外壳作为我的启动设备。

我从亚马逊订购了一个 CanaKit,其中包含我需要的一切,包括外壳、电源、Raspberry Pi 4 B 内存和 4GB 内存,以及一张带有 Raspbian 的 microSD 卡。我选择了 4GB 版本,因为它足以容纳 Windows 10 ARM,而且我想限制成本。

我组装了 Raspberry Pi 4 和带有风扇和散热器的外壳,插入了 microSD 卡,并为 Raspberry Pi 通电。它从 microSD 卡启动并允许我使用 NOOBS 安装 Raspbian。自从几年前我上次使用 Raspberry Pi 3 B 以来,NOOBS 似乎有所改进。 WiFi 工作正常,我能够更新 Raspbian.

对于 Windows 10 ARM 的存储,我使用了旧的 128GB SSD,我放在 USB 3.0 SATA 到 USB 外壳中。根据我的阅读,microSD 卡和 USB 3.0 上的 SSD 之间的区别是相当大的。

我使用 UUP dump website to download the necessary components and create the .iso file for a preview build of Windows 10 ARM. Then I used the WoR project tool 从 UUP 转储工具创建的 .iso 文件创建了一个可引导的 SSD。

此过程需要一些工具才能完成工作,但我发现这些工具对用户非常友好,并且构建预览 Windows 10 ARM .iso 文件非常简单。

一个警告:这些过程的文档似乎是一个移动的目标,工具也在改进。有关该过程的概述,请参阅以下内容:

这篇 Ars Technica 文章 New script makes it easy(ish) to put Windows 10 or 11 on a Raspberry Pi 提到了有关使用预览 Windows 10 个 ARM 组件的论点:

The script's creator argues that it violates no laws or Windows licensing agreements since it downloads all its code directly from Microsoft's servers and installs Windows in an unlicensed, deactivated state, just as it would install on a regular x86 PC without a product key. Microsoft only sells licenses of the ARM versions of Windows to OEMs. WoR-flasher has officially been tested using the 32-bit version of the Raspberry Pi OS (and that's what I used to create some install media, too), but it should run without issue on any Debian-based Linux distributions.

虽然提到必须更新 Raspberry Pi 4 固件以支持从 USB 启动,但我发现我在 2021 年 9 月购买的 Raspberry Pi 4 已经有了更新的固件.参见 Booting my Raspberry Pi 4 from a USB device

First, as I just said, USB boot is enabled by default on the Pi 4B (and the Pi 400, by the way), but there is a small caveat to that. It seems that some early bootloader firmware versions did not properly support this, so you have to be sure that your Raspberry Pi 4 has bootloader eeprom firmware dated Sep 3 2020 or later. There are two ways to do this; either remove the microSD card and then boot, so you can read the firmware date from the diagnostic screen, or simply run vcgencmd bootloader_version. I have three Pi 4 units (with 1GB, 2GB and 4GB of memory) which I got from the first batch available in Switzerland, and all of them have Sep 3 firmware so I assume the older firmware is not very common. If you happen to have an older version, the instructions for updating are given in the USB mass storage boot section of the Raspberry Pi Hardware Documentation.

The other requirement for USB boot is that you have to be booting Raspberry Pi OS version 2020-08-20 or later. In practical terms this simply means that you should use the latest Raspberry Pi OS image from the downloads page (which currently is 2020-12-02), or if you are going to copy an existing SD card check the contents of /etc/rpi-issue. I am not going to get into a discussion of booting other Linux distributions at this point, because I haven't had time to try it out myself yet.

我关闭了 Raspbian 并关闭了 Raspberry Pi。我使用 Raspbian 移除了 microSD 卡并将 USB 3.0 SSD 外壳插入 USB 3.0 端口并打开 Raspberry Pi 电源。 Windows 10 ARM 已初始化并启动。

我确实需要执行一些操作才能完成 Windows 10 ARM 安装:

  • 设置区域和键盘
  • 将以太网电缆插入 Raspberry Pi
  • 的 RJ-45 连接器
  • 使用个人 Microsoft 用户帐户

完成后,我就有了一个带有 Edge 网络浏览器的标准 Windows 10 桌面。使用 Edge 运行ning 简单检查任务管理器显示我有大约 1GB 的可用内存。

虽然任务管理器报告安装了 4 GB 内存,但 Windows 10 ARM 预览版在 Raspberry Pi 4 上仅使用了 3 GB 内存。我看到有人提到需要更改 BIOS 才能启用所有 4 GB 内存。

注意: 看来这里需要更改 BIOS,Only 3 GB of RAM are available. How can I fix this?

  • keep pressing the ESC key after plugging in the power cord, until you see the UEFI setup screen.
  • go to Device Manager -> Raspberry Pi Configuration -> Advanced Configuration and change Limit RAM to 3 GB to Disabled.
  • press ESC several times to go back, then Y to save the settings when prompted and finally reboot the board.

在 ARM 上使用 Visual Studio 2019 for MFC

我决定为我的测试 MFC 应用程序使用 Visual Studio 2019 Community Edition。

我使用 Visual Studio 创建了一个 MFC 项目。然后我尝试更改为失败的 ARM64 版本。

首先,我必须修改我的 Visual Studio 2019 安装以包含 ARM MFC 功能。这要求我使用 Visual Studio 2019 安装程序,该安装程序位于控制面板的应用和功能面板中。

按“修改”按钮并向下滚动到安装程序“单个组件”选项卡的底部附近。 Select C++v14.29 MFC for v142 build tools (ARM)C++v14.29 MFC for v142 build tools (ARM64).

在尝试各种方法来构建 ARM64 MFC 期间,我 运行 遇到了 MSB8041 链接器错误的问题,请参阅 MSB8041: MFC Libraries are required for this project

我对 Visual Studio 2019 安装做了几次修改,它终于似乎工作了,我能够对生成的 MFC 应用程序源代码主体进行 ARM64 MFC 编译。

我 运行 将 MFC 应用程序 .exe 转移到 Raspberry Pi 4,当我尝试 运行 它时,我收到 MFC 错误 .dll找不到。

然后我修改了构建属性以将 MFC 库用作静态库,t运行将生成的 MFC .exe 文件转移到 Raspberry Pi 4 然后能够运行它。

注意:我运行将 Visual Studio 2019 C++ Redistributable 安装程序的副本转移到 Raspberry Pi 4 和 运行 安装程序。这样做之后,测试 MFC 应用程序的版本将 MFC 用作 .dll 而不是静态库 运行 正确。该文件的名称是 VC_redist.arm64.exe,可以从 Microsoft 从 The latest supported Visual C++ downloads 下载,也可以在 Visual Studio 2019 的安装目录中找到。对于 Community Edition,该文件夹的路径是

C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Redist\MSVC\v142.

Nullsoft 脚本安装系统 (NSIS)

我之前使用过开源 Windows Installer builder,NSIS 或 Nullsoft Scriptable Install System,用于 Intel 上的 Windows 7 和 Windows 10,所以想尝试相同的软件Windows 10 ARM.

我认为可能有某种脚本编译器开关或设置来创建 Windows 10 ARM 安装程序但是阅读文档并查看支持论坛似乎没有 Windows 进行构建时有 10 个 ARM 目标可用。

支持论坛中的一个帖子提到,虽然使用由 NSIS 创建的针对 Windows 10 ARM 的安装程序特别不可用并且可能不可用,但 Windows 创建的安装程序由NSIS 应该在 Windows 10 Intel 和 Windows 10 ARM 上工作,微软最新的更改支持 Windows 10 ARM 上的 x86 应用程序。

我为 Windows 创建了一个简单的 NSIS 脚本,从一个旧脚本开始,用于不同的、更复杂的 x86 应用程序。我没有使用解决方案 compile/link 输出文件夹的标准路径,而是使用了 ARM64 compile/line 输出文件夹的路径。

我重新编译了我的 MFC 测试应用程序,然后编译了 NSIS 脚本以创建一个 Windows 安装程序。我 t运行 将其提交给我的 Raspberry Pi 4 运行 预览 Windows 10 ARM 版本。然后我 运行 安装程序成功完成。

MFC 测试程序显示在“开始”菜单中,我可以通过从“开始”菜单中选择应用程序来运行它。

然后我使用 Windows 控制面板将其卸载并正确卸载。

此测试的构建组件是使用 MFC 作为 .dll 编译的单个 MFC 应用程序。构建中只有两个文件:MFC 应用程序的 .exe 和一个放在同一文件夹中的短文本文件。我没有使用标准 Windows 应用程序路径来进行此测试,而是使用正确创建的 C:\framework\saratoga

附加说明和注意事项

Windows 10 来自 UUP 的 ARM 预览版本缺少 MFC .dll

根据我的经验,UUP 为 Raspberry Pi 4 构建的 Windows 10 ARM 预览版缺少 MFC .dll。我不知道三星、惠普、联想和微软等不同制造商为 Snapdragon 设备提供的标准 Windows 10 ARM 版本是否有 MFC .dll。

解决方法是使用静态 MFC 库编译 MFC 应用程序。

我想看看我的工作站上安装的 Visual Studio 2019 是否有 MFC .dll 的 ARM 版本,但找不到。我确实找到了一个用于 ARM 的可再发行 运行time 安装程序,所以可能里面有一个 MFC .dll。我没有使用可再发行的 运行time 安装程序,所以看起来标准 Visual Studio 2019 C++ 运行time 是来自 UUP 的 Windows 10 ARM 预览的一部分。

注意:在找到 Visual Studio 2019 C++ Redistributable for ARM 并将其运行安装在安装在 Windows 10 ARM 上之后Raspberry Pi 4、MFC .dll 现已可用,测试应用程序的非静态链接版本运行很好。

Windows 10 ARM 预览版本为测试模式

来自 UUP 的 Windows 10 ARM 预览版本在桌面右下角有一个注释,表明它处于“测试模式”,另外还有一个注释 Windows 需要已激活。

我不知道这是否意味着此 Windows 安装将在一定时间内无法使用。

Nullsoft 脚本安装系统

使用 NSIS 创建 Windows 应用程序安装程序似乎创建了适用于 Windows on Intel 以及 Windows 10 ARM 的安装程序。

据我所知,随着 Windows 10 ARM 的最新增强和对 x86 应用程序的支持,任何 Windows 安装程序创建的程序都使用经过编译的引擎对于 x86(不是 64 位应用程序)可以在 Windows 10 Intel 或 Windows 10 ARM 上使用。