CMake does not find Visual C++ compiler

前端 未结 27 2387
小鲜肉
小鲜肉 2020-11-29 18:51

After installing Visual Studio 2015 and running CMake on a previous project, CMake errors stating that it could not find the C compiler.

The C compiler ident         


        
27条回答
  •  情话喂你
    2020-11-29 19:32

    If none of the above solutions worked, then stop and do a sanity check.

    I got burned using the wrong -G string and it gave me this misleading error.

    First, run from the VS Command Prompt not the regular command prompt. You can find it in Start Menu -> Visual Studio 2015 -> MSBuild Command Prompt for VS2015 This sets up all the correct paths to VS tools, etc.

    Now see what generators are available from cmake...

    cmake -help

    ...... The following generators are available on this platform: Visual Studio 15 [arch] = Generates Visual Studio 15 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files. Optional [arch] can be "Win64" or "ARM". Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files. Optional [arch] can be "Win64" or "IA64". ...

    Then chose the appropriate string with the [arch] added.

    mkdir _build cd _build cmake .. -G "Visual Studio 15 Win64"

    Running cmake in a subdirectory makes it easier to do a 'clean' since you can just delete everything in that directory.

    I upgraded to Visual Studio 15 but wasn't paying attention and was trying to generate for 2012.

提交回复
热议问题