CMake : C and CXX compiler identification is unknown Win10 CMakeGUI - c++

So I am trying to configure a file based on this tutorial on youtube which is very simple :
https://www.youtube.com/watch?v=gYmgbqGfv-8
I use CMake GUI in Windows 10 and I have a running Visual Studio 2015 which is able to build c++ projects already (I've used it for some time)
I use "Visual Studio 15 2017"
I created a folder named hellocmake and hellocmake/build for both inputs:
my inputs
However when I tried to configure, it says that
CMake Error at CMakeLists.txt:1 (PROJECT):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:1 (PROJECT):
No CMAKE_CXX_COMPILER could be found.
The error log specifies that it can't find the two compiler files :
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
The system cannot find the file specified
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
The system cannot find the file specified
I tried downloading the "CMakeCXXCompilerId.cpp" and "CMakeCXXCompilerId.c" files and try to add them manually in the same folder, but it doesnt solve it
I tried to look up several other sources which have a similar case but I can't seem to understand them.
This problem didn't exist with my old computer so I assume it has something to do with the Visual Studio ?
Thank you guys, any help will be appreciated

You selected Visual Studio 2017 which you don't have installed. I think you confused the actual version number (which is 15 for VS2017) for the year in which the version was released. Pick a VS2015 generator (version number 14) and it should work.

I agree with #rubenvb's answer, add a tip: before you execute change "15" to "14", you should remove the "CMakeCache.txt" file.
cmake -G

Related

Building WinUI 3 Desktop Application using MSBuild with Visual Studio LLVM clang-cl

This question is an extension of the earlier question I had asked here.
Hi, When I create a WinUI project in Visual Studio, below is how the project structure looks like:
This project by default gets built using MSBuild as build system and default MSVS compiler.
However, I would like to build this project using MSBuild as build system and LLVM toolset for compilation and linking.
Is this possible to achieve?
This is how I am trying.
Installed clang-cl via VS load
Generated CMake cache using CMake like below:
cmake -G "Visual Studio 17 2022" -T ClangCl D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master>cmake -S . -G "Visual Studio 17 2022" -T ClangCL
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- The C compiler identification is Clang 15.0.1 with MSVC-like command-line
-- The CXX compiler identification is Clang 15.0.1 with MSVC-like command-line
And this automatically picks VS's LLVM's clang-cl.exe as compiler
But when I build like below, it fails.
D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master>cmake --build .
It fails with below error:
D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master\src/App.xaml.h(4,10):
fatal error : 'App.xaml.g.h' file not found [D:\Wi
nUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master\src\DemoApp.vcxproj]
D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master\src\MainWindow.xaml.cpp(9,3):
error : use of undeclared identifier 'Initi alizeComponent'
[D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master\src\DemoApp.vcxproj]
D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master\src\MainWindow.xaml.cpp(15,12):
error : function 'IsSettingsInvoked' with deduced return type cannot
be used before it is defined
[D:\WinUI\cmake-cpp-winrt-winui3-master_LLVMclang-cl\cmake-cpp-winrt-winui3-master\src\DemoApp.vcx
proj]
It seems MSBuild process did not generate App.xaml.g.h/App.xaml.g.xpp (and many more files that gets generated if we use MSVC Compiler )) which means that MSBuild did not run the xamlCompiler task to generate all the .g.h and g.cpp files.
Is there anything specific need to be done to resolve this issue? Am I missing something here?
Any pointers/suggestions will help.

CMake: How to specify VS2015.3 toolset with VS2017 installed

I have VS2017 installed, with both VS2017 (v141) and VS2015.3 (v140) toolset installed. I need to generate a solution with CMake and I want CMake to be "fooled" as if VS2015 is installed, so I can build the project with v140 toolset.
I know this question is possibly a duplicate of:
How cmake specify "Platform Toolset" for a Visual Studio 2015 project?
But the solution it provides doesn't help me.
The error messages are:
Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.15063.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:18 (project):
No CMAKE_C_COMPILER could be found.
I tried installing both VS2017 and VS2015.3 (IDE), but VS2015.3 refused to create even a simple console program.
Is there another way to generate a solution with v140 toolset?
(P.S. Don't tell me that I should generate with v141 toolset first and modify the toolset option in Visual Studio. That makes a big difference. )
I've just ran a test and it works for me with the following settings in CMake's GUI (Version 3.10.0 RC4):
Then I get the following output:
The CXX compiler identification is MSVC 19.0.24215.1
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
Generating done
And if I open the resulting solution it will - as expected - ask me:
Platform Toolset Mapping
From Marco Foco: Microsoft Visual C++ version Map:
If that don't work ...
First please check the CMakeError.log in your binary output directory. The error should give you a lead on what's wrong.
If that's not helping, you can try several things (besides re-installing VS, which I think won't solve the problem):
One of the Windows SDKs is not fully/correclty installed; Reinstall from Microsoft's web site
Try to give the cmake-gui administrative rights
Check if there is a GNU toolchain with GCC compiler in your PATH environment.
References
VS 2010 and CMake: 'rc' is not recognized as an internal or external command
MSBuild.exe has stopped cmake error
Environment variable used by CMake to detect Visual C++ compiler tools for Ninja

CXX and C Compiler identification is unknown [duplicate]

We are having trouble compiling a project using CMake (v2.8.12) under Windows 7 64Bit using Visual Studio 2012. CMake gives us the following errors. We already tried starting Cmake from the Visual Studio Command Line using admin rights. There seems to have been a similar bug in CMake 2.8.11: http://www.cmake.org/Bug/view.php?id=14440
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The C compiler identification is unknown
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:127 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The CXX compiler identification is unknown
Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
CMake Warning at src/CMakeLists.txt:44 (message):
SWIG was not found. You will not be able to compile for C#.
Configuring incomplete, errors occurred!
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeOutput.log".
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeError.log".
I had the same issue and fixed it running cmake as Admin
Those error messages
The C compiler identification is unknown
The CXX compiler identification is unknown
means CMake did find or assume a compiler but it wasn't able to compile a simple test program.
Take a look at CMakeFiles\CMakeError.log and check the error message there to see:
which compiler path/command line CMake did use
what the error message calling the compiler was
e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
If you add --debug-trycompile to the cmake call CMake will even keep the files it has tried to test compile (so you can copy/paste/re-run the command line from the error log in your cmd shell).
The last time I had this problem ...
The last time I had this problem was when my Visual Studio 2012 Professional standard installation did not install any Windows SDK (the error log was showing an missing SDK header).
To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe
Since I was missing this - or more accurate any SDK - I installed Windows 8.1 SDK (since Visual Studio 2012 does target Windows 8.x) and voila my CMake was able again to compile the (test) programs.
Reference
Does Visual Studio 2012 include the full Windows SDK
CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I was getting the terminal output:
The C compiler identification is unknown
The CXX compiler identification is unknown
I checked the CMakeError.log output:
\build\CMakeFiles\CMakeError.log
It showed the error:
warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.
Going back to visual Studio I needed to install the Windows 10 SDK:
After installing the SDK and running cmake it showed:
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.28.29334.0
The CXX compiler identification is MSVC 19.28.29334.0
And built successfully!
I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514 is missing.
After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.
http://www.microsoft.com/en-us/download/details.aspx?id=36020
I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:
Open command prompt for developers from Visual Studio tools.
Goto the directory where cmake.exe is present.
Run it.
Lets hope it works for you as well.
For some reason, deleting the build folder in my machine, solved the issue.
cmake:
The cmake assume that you set g++ compiler path accurately.In case due any reason if it did't find compiler path{/usr/bin/g++} then it throw an error like:
**The CXX compiler identification is unknown**
So given step will short out this error:
Locate your compiler CXX path{for g++ path under Linux is :/usr/bin/g++}
Set the Compiler Path and export it configuration: PATH=/usr/bin:$PATH;export PATH
Export compiler like : export CXX=/usr/bin/g++-7
Here we assume that g++,cmake,build-essential install in your Linux system...!!
Same problem here with cmake 2.8.12 and visual studio 10. Cmake may not be able to find the compiler. I solved the problem by uninstalling latest version and installed cmake 2.8.10.
I just encounter with this issue, after I uninstalled some MS software.
I fixed it by repair visual studio 2012.
First go to [Control panel], then select visual studio and repair it,things will go right now.
Make sure you select the proper version of visual Studio.
For example, Visual Studio 2012 is version 11.
I had the same problem and I had to use the "File -> Delete Cache", since I accidentally configured CMake to use wrong visual studio version.
If you use CMake 3.4.0, try upgrading to a newer version. A bug concerning this was fixed relatively recently (see the bug report).
Make sure that you have installed Clang tools
open tools -> Get tools and features, select individual components, search cmake, then uninstall cmake and then re-install cmake, when complete, restart your computer.
I was seeing this on ubuntu - issue was cmake was assuming clang++ as c compiler.
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/clang++-9"
To fix it, export C, C++ compiler paths:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

PietCreator C++ won't compile

I'm trying to compile PietCreator using CMake, but I get various error codes. How can I fix this?
Error codes:
Compiling the C compiler identification source file "CMakeCCompilerId.c"failed.
Compiler:
Build flags:
Id flags:
The output was:
The system can not find the file specified
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler:
Build flags:
Id flags:
The output was:
The system can not find the file specified
Here is source: https://github.com/Ramblurr/PietCreator
Compiling with CMake 3.3.0 and Visual Studio 14 2015 Win64 on Windows 8.1 64x
When building project files with CMake, you have to make sure to install all dependencies and (usually) use the compiler suggested in the docs of whatever source code you are building project files for. In this case, you'll need Qt 4.x installed, along with the Visual C++ 2008 compiler. After doing that, you should be able to tell CMake to use that version compiler, set the QT 4.x directory in the main window of the GUI (or by command line), and have your .sln file created.

The CXX compiler identification is unknown

We are having trouble compiling a project using CMake (v2.8.12) under Windows 7 64Bit using Visual Studio 2012. CMake gives us the following errors. We already tried starting Cmake from the Visual Studio Command Line using admin rights. There seems to have been a similar bug in CMake 2.8.11: http://www.cmake.org/Bug/view.php?id=14440
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The C compiler identification is unknown
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:446 (execute_process):
execute_process given COMMAND argument with no value.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCompilerId.cmake:48 (CMAKE_DETERMINE_COMPILER_ID_VENDOR)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeDetermineCXXCompiler.cmake:127 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
The CXX compiler identification is unknown
Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
CMake Warning at src/CMakeLists.txt:44 (message):
SWIG was not found. You will not be able to compile for C#.
Configuring incomplete, errors occurred!
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeOutput.log".
See also "C:/Users/hci/laser_control/CMakeFiles/CMakeError.log".
I had the same issue and fixed it running cmake as Admin
Those error messages
The C compiler identification is unknown
The CXX compiler identification is unknown
means CMake did find or assume a compiler but it wasn't able to compile a simple test program.
Take a look at CMakeFiles\CMakeError.log and check the error message there to see:
which compiler path/command line CMake did use
what the error message calling the compiler was
e.g. LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
If you add --debug-trycompile to the cmake call CMake will even keep the files it has tried to test compile (so you can copy/paste/re-run the command line from the error log in your cmd shell).
The last time I had this problem ...
The last time I had this problem was when my Visual Studio 2012 Professional standard installation did not install any Windows SDK (the error log was showing an missing SDK header).
To verify your SDK installation e.g. check that you have any Resource Compiler installed. It should be in a path similar to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v[some version]\bin\RC.Exe
Since I was missing this - or more accurate any SDK - I installed Windows 8.1 SDK (since Visual Studio 2012 does target Windows 8.x) and voila my CMake was able again to compile the (test) programs.
Reference
Does Visual Studio 2012 include the full Windows SDK
CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
I was getting the terminal output:
The C compiler identification is unknown
The CXX compiler identification is unknown
I checked the CMakeError.log output:
\build\CMakeFiles\CMakeError.log
It showed the error:
warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.
Going back to visual Studio I needed to install the Windows 10 SDK:
After installing the SDK and running cmake it showed:
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.28.29334.0
The CXX compiler identification is MSVC 19.28.29334.0
And built successfully!
I had similar problem also, if you are using Microsoft Visual Studio 2012, that might be because of update of KB2781514 is missing.
After I installed following update, CMake start to detect Visual Studio 2012 c/c++ compilers correctly.
http://www.microsoft.com/en-us/download/details.aspx?id=36020
I faced the same problem. Building and running a project from Visual Studio didn't work for me. However following worked for me:
Open command prompt for developers from Visual Studio tools.
Goto the directory where cmake.exe is present.
Run it.
Lets hope it works for you as well.
For some reason, deleting the build folder in my machine, solved the issue.
cmake:
The cmake assume that you set g++ compiler path accurately.In case due any reason if it did't find compiler path{/usr/bin/g++} then it throw an error like:
**The CXX compiler identification is unknown**
So given step will short out this error:
Locate your compiler CXX path{for g++ path under Linux is :/usr/bin/g++}
Set the Compiler Path and export it configuration: PATH=/usr/bin:$PATH;export PATH
Export compiler like : export CXX=/usr/bin/g++-7
Here we assume that g++,cmake,build-essential install in your Linux system...!!
Same problem here with cmake 2.8.12 and visual studio 10. Cmake may not be able to find the compiler. I solved the problem by uninstalling latest version and installed cmake 2.8.10.
I just encounter with this issue, after I uninstalled some MS software.
I fixed it by repair visual studio 2012.
First go to [Control panel], then select visual studio and repair it,things will go right now.
Make sure you select the proper version of visual Studio.
For example, Visual Studio 2012 is version 11.
I had the same problem and I had to use the "File -> Delete Cache", since I accidentally configured CMake to use wrong visual studio version.
If you use CMake 3.4.0, try upgrading to a newer version. A bug concerning this was fixed relatively recently (see the bug report).
Make sure that you have installed Clang tools
open tools -> Get tools and features, select individual components, search cmake, then uninstall cmake and then re-install cmake, when complete, restart your computer.
I was seeing this on ubuntu - issue was cmake was assuming clang++ as c compiler.
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler
"/usr/bin/clang++-9"
To fix it, export C, C++ compiler paths:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++