CMake does not find Visual C++ compiler

前端 未结 27 2198
小鲜肉
小鲜肉 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:30

    In my case the issue was that the parent project, which is including googletest via

    add_subdirectory(gtest_dir)
    

    was defined as

    PROJECT( projname CXX )
    

    Somehow, CMake does not recognize

    PROJECT(sub_project_name CXX C)
    

    since the C compiler is not set in the parent.

    I solved the issue by using

    PROJECT( projname CXX C)
    

    in my main CMakeLists.txt file.

    0 讨论(0)
  • 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 <config> 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

    ...<snip>... 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.

    0 讨论(0)
  • 2020-11-29 19:32

    I had a related problem: the Visual C++ generators were not even on the list when running cmake --help.

    I ran where cmake in console and found that cygwin also provides its own cmake.exe file, which was being used. Changing the order of directories in PATH fixed the problem.

    0 讨论(0)
  • 2020-11-29 19:33

    I ran into the same issue and fixed it by relaunching the Visual Studio Install and checking the following option:

    Windows and Web Development / Universal Windows App Development Tools / Windows 10 SDK

    It contains the standard C++ headers used in most applications and therefore it is often necessary to install it as well.

    0 讨论(0)
  • 2020-11-29 19:33

    I had this issue with CMake GUI and the VS 21019 Community Edition. I think I may have installed CMake before Visual Studio - certainly after I updated CMake 3.15.2 to 3.15.3 the problem went away.

    0 讨论(0)
  • 2020-11-29 19:35

    i found this sollution at stackoverflow and i work for me although not working other sollutions if you have a windows 10 OS, doing the following steps will fix the problem:

    1) go to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin

    2) then copy RC.exe and RcDll from this file

    3) go to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin and paste the two files you have copied into it.

    thats all i hope it is helpful...

    0 讨论(0)
提交回复
热议问题