C++ xxxxxx.exe 不是有效的 Win32 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11305633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 15:01:43  来源:igfitidea点击:

xxxxxx.exe is not a valid Win32 application

c++cwindowsvisual-studio-2012

提问by user525717

I have small C/C++ project in Visual Studio 2012 RC

我在 Visual Studio 2012 RC 中有一个小的 C/C++ 项目

This applications parses the argv and then calling another .exe file with ShellExecute

此应用程序解析 argv,然后调用另一个 .exe 文件 ShellExecute

My application works perfect on Windows7 but on Windows XP x86 trhows Is not a valid Win32 application error.

我的应用程序在 Windows7 上运行良好,但在 Windows XP x86 上 trhows 不是有效的 Win32 应用程序错误。

I have compiled it with Mutli-thread(/MT) and Win32 Platform

我已经用多线程(/MT) 和 Win32 平台编译了它

This is my #includes

这是我的#includes

#include <string>
#include <iostream>
#include <Windows.h>
#include <fstream>
#include <cstdio>
#include <vector>
#include <windowsx.h>
#include <shlobj.h>
#include <stdio.h>
#include <tchar.h>
#include <direct.h>

Thanks

谢谢

回答by noelicus

It's Feb 2013, and I can now target XP in VS2012 by setting:

现在是 2013 年 2 月,我现在可以通过设置在 VS2012 中针对 XP:

Project Properties -> General -> Platform Toolsetto:

项目属性 -> 常规 -> 平台工具集到:

Visual Studio 2012 - Windows XP (v110_xp)

Visual Studio 2012 - Windows XP (v110_xp)

You will have to redistribute the msvcp110.dll libraries et al with your application, which are found here: "<Program Files>\Microsoft Visual Studio 11.0\VC\redist\x86\Microsoft.VC110.CRT\"

您必须将 msvcp110.dll 库等与您的应用程序一起重新分发,可在此处找到: "<Program Files>\Microsoft Visual Studio 11.0\VC\redist\x86\Microsoft.VC110.CRT\"



Update Aug 2015 with Visual Studio 2015

使用 Visual Studio 2015 更新 2015 年 8 月

There seems to be quite a selection now. I was able to compile application in VS2015 using Visual Studio 2015 - Windows XP (v140_xp)setting. To make it actually run on Win XP I had to deploy (copy alongside application) msvcr100.dllfor Release build and msvcr110.dlland msvcr100d.dllfor Debug build (note there is a difference in numbers 100 and 110, also debug lib msvcr100d.dllmay not be redistributable) Targeting Windows XP with Visual Studio 2015

现在似乎有很多选择。我能够使用Visual Studio 2015 - Windows XP (v140_xp)设置在 VS2015 中编译应用程序。为了让它真正在 Win XP 上运行,我必须部署(与应用程序一起复制)msvcr100.dll用于发布版本和msvcr110.dllmsvcr100d.dll用于调试版本(注意数字 100 和 110 有区别,还有调试库msvcr100d .dll可能不可再发行) 使用 Visual Studio 2015 以 Windows XP 为目标

回答by RedX

VS 2012 applications cannot be run under Windows XP.

VS 2012 应用程序无法在 Windows XP 下运行。

See this VC++ blogon why and how to make it work.

请参阅此VC++ 博客,了解为什么以及如何使其工作。

It seems to be supported/possible from Feb 2013. See noelicus answer belowon how to.

似乎从 2013 年 2 月开始支持/可能。有关如何操作,请参阅下面的 noelicus 答案

回答by Andrey Sorich

While seleted answer was right time ago, and then noelicus gave correct update regarding v110_xp platform toolset, there is still one more issue that could produse this behaviour.

虽然选择的答案是正确的,然后 noelicus 给出了关于 v110_xp 平台工具集的正确更新,但还有一个问题可能会导致这种行为。

A note about issue was already posted by mahesh in his comment, and I would like to highlight this as I have spend couple of days struggling and then find it by myself.

mahesh 在他的评论中已经发布了一个关于问题的说明,我想强调这一点,因为我花了几天的时间挣扎,然后自己找到它。

So, if you have a blank in "Configuration Properties -> Linker -> System -> Subsystem" you will still get the "not valid Win32 app" error on XP and Win2003 while on Win7 it works without this annoying error. The error gone as soon as I've put subsystem:console.

因此,如果您在“配置属性 -> 链接器 -> 系统 -> 子系统”中有空白,您仍然会在 XP 和 Win2003 上收到“无效的 Win32 应用程序”错误,而在 Win7 上它可以正常工作而不会出现这个烦人的错误。一旦我放置了子系统:控制台,错误就消失了。

回答by Alessandro Jacopson

There are at least two solutions:

至少有两种解决方案:

  1. You need Visual Studio 2010 installed, then from Visual Studio 2010, View -> Solution Explorer -> Right Click on your project -> Choose Properties from the context menu, you'll get the windows "your project name" Property Pages -> Configuration Properties -> General -> Platform toolset, choose "Visual Studio 2010 (v100)".
  2. You need the Visual Studio 2012 Update 1described in Windows XP Targeting with C++ in Visual Studio 2012
  1. 您需要安装 Visual Studio 2010,然后从 Visual Studio 2010,查看 -> 解决方案资源管理器 -> 右键单击​​您的项目 -> 从上下文菜单中选择属性,您将获得窗口“您的项目名称”属性页 -> 配置属性 -> 常规 -> 平台工具集,选择“Visual Studio 2010 (v100)”。
  2. 您需要Windows XP Targeting with C++ in Visual Studio 2012 中描述的Visual Studio 2012 Update 1

回答by Matsk

For me, this helped: 1. Configuration properties/General/Platform Toolset = Windows XP (V110_xp) 2. C/C++ Preprocessor definitions, add "WIN32" 3. Linker/System/Minimum required version = 5.01

对我来说,这有帮助: 1. 配置属性/常规/平台工具集 = Windows XP (V110_xp) 2. C/C++ 预处理器定义,添加“WIN32” 3. 链接器/系统/最低要求版本 = 5.01

回答by karlphillip

I had the same issue on Windows XPwhen running an application built with a static version of Qt 5.7.0(MSVC 2013).

在运行使用静态版本的Qt 5.7.0(MSVC 2013)构建的应用程序时,我在Windows XP上遇到了同样的问题。

Adding the following line to the project's .profile solved it:

将以下行添加到项目的.pro文件中解决了这个问题:

QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01

回答by David H

I believe this error can also be thrown if your project is targeting a framework version that is not installed on the server you are deploying to.

我相信如果您的项目针对的是未安装在您部署到的服务器上的框架版本,也会引发此错误。

回答by Zac

I got this problem while launching a VS2013 32-bit console application in powershell, launching it in cmd did not issue this problem.

我在 powershell 中启动 VS2013 32 位控制台应用程序时遇到了这个问题,在 cmd 中启动它没有出现这个问题。