繁体   English   中英

从 CMD 编译时更改平台工具集

[英]Change Platform Toolset when compiling from CMD

我想通过 Visual Studio 命令行工具编译一个C++程序。 我想针对32 bit Windows XP的可执行文件。 尝试使用x86 Native Tools Command Prompt for VS 2019以通常的方式编译它,但它在Windows XP上不起作用,但在我的Windows 10机器上运行良好。

我采取的步骤:

  • 打开x86 Native Tools Command Prompt for VS 2019
  • cd到项目目录。 我将有 2 个文件夹sourcesheaders ,它们分别包含.cpp.h文件。
  • 执行命令cl sources\*.cpp /EHsc /D_WIN32_WINNT=0x050103 /I headers /I <path to boost> /link /libpath <path to boost>\boost_1_77_0\bin\x86\lib\libboost_program_options-vc142-mt-s-x32-1_77.lib /out:exec_xp.exe (项目使用boost库)。

试过这个,但它不起作用。 /D \"_USING_V110_SDK71_\"似乎什么都不做,编译器无法识别/SUBSYSTEM:WINDOWS,5.01部分。

我从这个 Microsoft 页面了解到我们应该安装已弃用的工具集以针对WinXP进行编译。 我继续使用Visual Studio Installer并安装了C++ Windows XP Support for VS 2017 (v141) tools [Deprecated] ,如教程中所述。

但是现在呢? 我该如何使用这个工具集? 我在我的电脑上找不到它,更不用说使用它了! Visual Studio Installer说它位于C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools ,但它太含糊了。

更新:

尝试使用msbuild /p:PlatformToolset=v141_xp ,出现此错误:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(439,
5): error MSB8020: The build tools for v141_xp (Platform Toolset = 'v141_xp') cannot be found. To build using the v141_
xp build tools, please install v141_xp build tools.  Alternatively, you may upgrade to the current Visual Studio tools
by selecting the Project menu or right-click the solution, and then selecting "Retarget solution"

这表明,编译器看不到v141_xp工具集。 我想知道为什么? 它确实已安装,我是通过 Visual Studio 安装程序安装的。

我建议您可以尝试设置PlatformToolset 属性

msbuild myProject.vcxproj /p:PlatformToolset=…

更多细节,我建议你可以参考文档: MSBuild command-line reference

暂无
暂无

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

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