Reputation: 141
I am currently trying to compile a project in CMake 3.10.0 and it keeps giving the above error box and this
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_CXX_COMPILER could be found.
Configuring incomplete, errors occurred!
See also "C:/build/CMakeFiles/CMakeOutput.log".
See also "C:/build/CMakeFiles/CMakeError.log".
I am currently running Microsoft Visual Studio 15 2017 and when I am configuring it, I am using x64.
Upvotes: 7
Views: 62770
Reputation: 960
Caveat: This perhaps too obvious and facile to even post, but since @N.S's answer made me think to try it, and it worked...
MacOS only: (using 13.1)
Xcode 14.2
Upvotes: 0
Reputation: 302
In addition to checking if I can compile a C++ program and rechecking my Visual Studio components, updating my windows SDK to the new version, I installed a another version of Cmake and it worked.
Upvotes: 0
Reputation: 1
Make sure that you named CMakeLists.txt
correctly. Once I omitted a 's' at the end of the list, so I got the same error. But when I added 's' it worked well.
Upvotes: 0
Reputation: 31
In my case, I hadn't selected the correct visual studio version in the configuration panel. Once I did that everything worked correctly.
Upvotes: 0
Reputation: 63
Another version of this error occurred in my case when I wanted to build librealsense from source using cmake, in my case the silly error was providing the source code path in librealsense E:\librealsense-2.49.0\src rather i should have provided E:\librealsense-2.49.0 alone. this worked for me.
Upvotes: 0
Reputation: 956
To Solve the problem, I just downloaded the last version of the opencv and opencv_contrib repositories(both on the same branch named '3.4').
Upvotes: 0
Reputation: 658
First step, Click the File, select Delete Cache, Second step, Click the Configure, select the VS15 2017, then Done.
Upvotes: 3
Reputation: 1477
i had same problem when using vs 2015 but after installing vs 2017 it solved. I think you should repair your visual studio 2017 and try again. if cmake don`t let you configure with new vs in file tab clear use "delete cache" and try again
Upvotes: 9
Reputation: 2304
When you installed Visual Studio 2017, did you install the Visual C++ compilers? It's not enabled by default. Go to Add or Remove programs and try Repairing/Modifying it to make sure Visual C++ is included.
This is going to sound like a stupid suggestion but if you've just installed VS 2017, make sure you're actually able to compile a sample C++ solution. Yes, you would be surprised by the amount of people I've seen with this error that simply didn't realize their compiler wasn't installed.
My third suggestion would be to try opening the x86 or x64 Native Tools Command Prompt and try running your CMake build again. The problem, as I'm sure you've noticed haha, is that it can't find your C compilers. Running these Command Prompts will ensure your correct environment variables are set. If this fails, your C compilers are missing and you need to re-install VS2017. If this works that means there's an issue with your environment PATH.
Upvotes: 4