如何在Visual Studio 2017中编译Windows XP的代码
How to compile code for Windows XP in Visual Studio 2017
我试图在Windows 10上的Visual Studio 2017中为Windows XP编译一个基本的hello world程序。但它给出了一些错误,如图像所示。
我已经尝试了其他Stack Overflow帖子中提到的关于这个问题的步骤,并更改了平台工具"Visual Studio 2017 - Windows XP(v141_xp("。
#include<iostream>
using namespace std;
int main() {
cout << "Hello worldn";
}
1>------ Build started: Project: WindowsProject1, Configuration: Debug Win32 ------
1>C:Program Files (x86)Microsoft Visual Studio2017CommunityCommon7IDEVCVCTargetsPlatformsWin32PlatformToolsetsv141_xpToolset.targets(39,5): warning MSB8051: Support for targeting Windows XP is deprecated and will not be present in future releases of Visual Studio. Please see https://go.microsoft.com/fwlink/?linkid=2023588 for more information.
1>stdafx.cpp
1>c:program files (x86)microsoft sdkswindowsv7.1aincludeobjbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
1>c:program files (x86)microsoft sdkswindowsv7.1aincludegdiplusheaders.h(891): error C4596: 'EmfToWmfBits': illegal qualified name in member declaration
1>c:program files (x86)microsoft sdkswindowsv7.1aincludegdiplusstringformat.h(220): error C4596: 'GetTrimming': illegal qualified name in member declaration
1>Done building project "WindowsProject1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
您在这里遇到的是XP兼容SDK头文件中的问题。这个问题实际上相当晦涩难懂,但幸运的是,相对容易处理:你只需要"放松"编译器使用的一致性检查的严格性......
为此,请在">解决方案资源管理器"中右键单击你的项目,然后选择"属性"。在调用的属性页上,选择"C/C++"选项卡,然后选择"语言"子选项卡。在随后显示的页面中,确保选择"一致性模式"到">否"。这应该可以解决问题。
请随时要求进一步澄清和/或解释。
您没有说您开始使用什么模板,但我怀疑您启用了一致性模式 (/permissive-
(。转到"项目->属性"-> C/C++ -> 语言,并将"一致性模式"设置为"否"。
用于支持Windows XP的旧Windows 7.1a SDK从未更新以符合/permissive-
。
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 在Linux for Windows上编译C++代码时出错
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 升级到 Windows 10 版本 1809 SDK 后,我无法编译使用 C++/WinRT 的项目
- 在Linux上使用Clang / OLLVM交叉编译helloworld Windows可执行文件时的问题
- Eclipse 没有在 Windows (C++) 中编译.exe
- 尝试在Windows上执行C++时出错(通过MinGW编译)
- 编译的C可执行文件被Windows defender检测为病毒
- gcc:"在Windows上编译时找不到-lasound"
- 坚持编译QDoc以在Windows上构建qt5
- MSYS2 MinGW64 在 Windows 上构建 GMP/MPFR 作为静态库,并将它们链接到使用 CL 编译的
- SFML 交叉编译 for Windows on Linux.
- 使用 MinGW 在 Windows 上的命令行编译C++文件
- 如何使用 openmp 编译 c++?(在 Windows 10 中使用 G++)
- 如何使用Visual Studio为windows编译GMP
- 在 Linux 上为 Windows 编译多线程应用程序 [ C++ ]
- Rcpp Windows 编译失败
- 从 Windows 编译 OSX 的C++
- 从 Linux 上的 Windows 编译 OpenGL 应用程序
- 如何为64位Windows编译WSO2 Web服务框架- c++ ?