![](/img/trans.png)
[英]Access violation writing on platform toolset v140 DLL when call from v100
[英]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 个文件夹sources
和headers
,它们分别包含.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.