Reputation: 1777
I would like to compile a C++
program via Visual Studio command line tools. I would like to target the executable for 32 bit Windows XP
. Tried compiling it the usual way, using x86 Native Tools Command Prompt for VS 2019
, but it doesn't work on Windows XP
, though runs fine on my Windows 10
machine.
Steps I take:
x86 Native Tools Command Prompt for VS 2019
.cd
to the project directory. There I'll have 2 folders sources
and headers
, which shall contain .cpp
and .h
files respectively.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
(the project uses the boost
library).Tried this, but it doesn't work. /D \"_USING_V110_SDK71_\"
seems to do nothing, and the /SUBSYSTEM:WINDOWS,5.01
piece isn't recognized by the compiler.
I have learnt from this Microsoft page that we should install deprecated Toolset to compile for WinXP
. I went ahead to Visual Studio Installer
and installed the C++ Windows XP Support for VS 2017 (v141) tools [Deprecated]
, as said in the tutorial.
But what now? How can I use this Toolset? I can't find it anywhere on my computer, let alone use it! Visual Studio Installer
says it's located under C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
, but it's too vague.
UPD:
Tried with msbuild /p:PlatformToolset=v141_xp
, getting this error:
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"
Which suggests, the compiler doesn't see the v141_xp
toolset. I wonder why? It's installed for sure, I did it via the Visual Studio Installer.
Upvotes: 0
Views: 1152
Reputation: 4017
I suggest you could try to set the PlatformToolset property:
msbuild myProject.vcxproj /p:PlatformToolset=…
For more details, I suggest you could refer to the Doc:MSBuild command-line reference
Upvotes: 2