gpt4 book ai didi

c++ - 如何在 windows 7/visual studio 2008 下为 windows XP 编译

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:48 29 4
gpt4 key购买 nike

我正在运行 Windows 7 和 Visual Studio 2008 Pro,并试图让我的应用程序在 Windows XP SP3 上运行。

这是一个真正最小的命令行程序,所以应该有任何可笑的依赖:

// XPBuild.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
printf("Hello world");
getchar();
return 0;
}

我在某处读到 defining several constants such as WINVER应该允许我为其他平台编译。我已经尝试将以下内容添加到我的 /D 编译器选项中:

;WINVER=0x0501;_WIN32_WINNT 0x0501;NTDDI_VERSION=NTDDI_WINXP

但这并没有什么不同。当我在我的 Windows XP 机器上运行它时(实际上在 virtualbox 中运行)我得到以下错误:

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

所以我错过了什么?是否需要其他东西来运行 MSVC 编译程序或不同的编译器选项或其他东西?

最佳答案

您错过的很可能是 VC++ 程序需要安装运行时(除非您静态链接,这不是默认设置)- 如果它们不按顺序显示,您显示的错误消息正是您收到的错误消息.

尝试安装 Microsoft Visual C++ 2008 SP1 Redistributable Pack在 XP 机器上 - 您很可能会看到您的程序无需任何更改即可运行。

关于c++ - 如何在 windows 7/visual studio 2008 下为 windows XP 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2581752/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com