I am learning to use CMake by the tutorial:http://derekmolloy.ie/hello-world-introductions-to-cmake/.I tried compiling my hello_world.cpp using cmake but i am getting this error message on MSys2 in Windows 10:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error at CMakeLists.txt:3 (project):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "D:/Hello_World/CMakeFiles/CMakeOutput.log".
See also "D:/Hello_World/CMakeFiles/CMakeError.log".
This is my first post here.I am sorry for any mistake.
cl
is the Microsoft Visual Studio compiler. IIRC MSYS (and MSYS2) doesn't by default install MinGW (which is the compiler component of the package). Have you installed MinGW? From the MSYS shell, what happens if you run the programgcc
? And from where are you runningcmake
? – Stockbrokergcc --version
in my Msys window -- do you get a proper gcc version output or error command not found? If it works, then you should havegcc
as your compiler on line-3 and notcl
(which iscl.exe
the VS compiler). Now you can configurecmake
to work withcl.exe
, but that wouldn't be through Msys. – Kabukig++
if you are building C++,gcc
for C. My bad for not catching the [c++] tag. – KabukiCMakeCache.txt
from your build folder and runcmake -G "MSYS Makefiles" .
, i.e. explicitly set the generator. – Devolve"CMake Error at CMakeLists.txt:3"
. Socmake
is trying to usecl
s the default compiler. You need to either changeCMakeLists.txt
to useg++
or specify theCC=gcc CXX=g++
on the command line beforecmake
(note you should remove any existingbuild
directory that was created whencmake
attempted to usecl
). – Kabukicmake
should be callingmake
with MinGW, notnmake
(VS make). – Kabuki