Home > database >  Using "Visual Studio 15 2017" compiler in Visual Studio 2022 IDE
Using "Visual Studio 15 2017" compiler in Visual Studio 2022 IDE

Time:09-03

I have recently downloaded the Visual Studio 2022 IDE. During installation, I selected "Desktop development with C " and "MSVC v141 - VS 2017 C x64/x86 build tools" (as answers to similar questions had suggested). I want to compile using cmake -G "Visual Studio 15 2017 Win64" .. but get the following error:

CMake Error at CMakeLists.txt:83 (project):
  Generator

    Visual Studio 15 2017 Win64

  could not find any instance of Visual Studio.

cmake --help returns a list of available generators (shortened for readability): The following generators are available on this platform (* marks default):

* Visual Studio 17 2022        = Generates Visual Studio 2022 project files.
                                 Use -A option to specify architecture.
  Visual Studio 16 2019        = Generates Visual Studio 2019 project files.
                                 Use -A option to specify architecture.
  Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                                 Optional [arch] can be "Win64" or "ARM".
...

This output makes me think that Visual Studio 15 2017 should be available, but it is nevertheless not being found.

cmake --version returns cmake version 3.23.22060601-MSVC_2. How could I use the Visual Studio 15 2017 generator instead of the newest Visual Studio 17 2022?

CodePudding user response:

How could I use the Visual Studio 15 2017 generator instead of the newest Visual Studio 17 2022?

Answering this directly: find and install Visual Studio 2017. That's a bad solution, though.

I selected "Desktop development with C " and "MSVC v141 - VS 2017 C x64/x86 build tools" (as answers to similar questions had suggested)

Ah, so you want to target MSVC v141. No problem. Use the generator for the toolchain you already have installed (VS2022) and then tell it to use the v141 toolset with the -T flag, like so:

cmake -G "Visual Studio 17 2022" -T v141 [...other args...]
  • Related