在64位计算机上使用Visual Studio编译32位应用程序

mt2*_*t22 5 c visual-studio-2010 32bit-64bit visual-studio

我正在尝试使用Visual Studio 2010在Windows 7全新安装的64位计算机上编译一个简单的32位Hello World应用程序.安装Visual Studio后,我还安装了"Windows SDK for Windows 7和.NET Framework 4".我构建了选择"Win32"作为平台的应用程序.它可以在Windows 7上运行,但是如果我在使用Windows XP Professional的32位计算机上运行应用程序(全新安装,没有软件和Service Pack),它似乎无法解决此错误:

"This application has failed to start because msvcr100.dll was not found"
Run Code Online (Sandbox Code Playgroud)

如果它有用,Dependency Walker会检测到2个错误(有关详细信息,请参阅链接图片):

"Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module."
"Error: Modules with different CPU types were found."
Run Code Online (Sandbox Code Playgroud)

http://img820.imageshack.us/img820/4725/errordp.png(Pitect)

我该如何解决?谢谢!

era*_*ran 2

不要相信 Dependency Walker 对此...它清楚地表明您的 exe 是 32 位的。您的问题出在 VC 可再发行组件上,即 CRT dll - 在 VS 安装中查找 vcredist_x86.exe。您应该在运行应用程序之前运行它。

另一种选择是静态链接 CRT。请参阅/MT 选项。会使你的 exe 更大,但保存 vcredist 的东西。