简体   繁体   English

从Windows 7上的VS2012到Windows XP交叉编译hello world程序

[英]Cross-compile hello world program from VS2012 on Windows 7 to Windows XP

I am trying to cross-compile the following hello-world program 我正在尝试交叉编译以下hello-world程序

#include <iostream>

int main()
{
    std::cout << "Hello world!" << std::endl;
}

My host platform uses Microsoft Visual Studio Express 2012 for Windows Desktop on a Windows 7 SP1 64-bit machine. 我的主机平台在Windows 7 SP1 64位计算机上将Microsoft Visual Studio Express 2012用于Windows桌面。 My target platform is a 32 bit Windows XP Embedded device (Version 2002 Service Pack 2) with 248 MB of RAM. 我的目标平台是具有248 MB RAM的32位Windows XP Embedded设备(2002 Service Pack 2版)。 I follow the command line instructions at http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx to do the cross-compilation. 我按照http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx上的命令行说明进行交叉编译。

The fact that I can successfully run my hello_world.exe in the 'IE6 on XP' virtual machine from https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/ makes me feel confident that the cross-compiling went fine. 我可以从https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/在“ IE6 on XP”虚拟机中成功运行我的hello_world.exe,这使我充满信心交叉编译很好。 However, when I copy the hello_world.exe to my Windows XP Embedded device and try to run it, I get the following Application Error: 但是,当我将hello_world.exe复制到Windows XP Embedded设备并尝试运行它时,出现以下应用程序错误:

在此处输入图片说明

Dependency Walker (running on the XP Embedded device) does not show me any DLL problems: Dependency Walker(在XP Embedded设备上运行)没有显示任何DLL问题:

在此处输入图片说明 在此处输入图片说明

I am stuck here. 我被困在这里。 If anybody can shed a light on why I am getting this strange Application Error and how I can fix it, I would be happy to hear! 如果有人能弄清楚为什么我会收到这个奇怪的应用程序错误以及如何解决它,我很高兴听到!

Problem solved. 问题解决了。 The problem was that the CPU of the embedded device did not support certain instructions. 问题是嵌入式设备的CPU不支持某些指令。 I was compiling my hello_world program without the /arch option, but for Visual Studio 2012 that means that SSE2 instructions are enabled. 我当时在编译没有/arch选项的hello_world程序,但是对于Visual Studio 2012,这意味着启用了SSE2指令。 Compiling my hello_world program with the /arch:IA32 option solves the problem. 使用/arch:IA32选项编译我的hello_world程序可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM