[c++] CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found

I'm trying make a Visual Studio solution with CMake to compile the latest version of aseprite and CMake keeps giving me the:

No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.

I've already downloaded GCC, and I'm using Visual Studio 2015.

I'm following this tutorial:

https://github.com/aseprite/aseprite/blob/master/INSTALL.md

This question is related to c++ visual-studio gcc cmake visual-studio-2015

The answer is


I also experienced this error when working with CMake:

No CMAKE_C_COMPILER could be found.
No CMAKE_CXX_COMPILER could be found.

The 'warning' box in the MSDN library article Visual C++ in Visual Studio 2015 gave me the help that I needed.

Visual Studio 2015 doesn't come with C++ installed by default. So, creating a new C++ project will prompt you to download the necessary C++ components.


For me, this problem went away on Windows when I moved my project to a shallower parent directory, i.e. to:

C:\Users\spenc\Desktop\MyProjectDirectory

instead of

C:\Users\spenc\Desktop\...\MyProjectDirectory.

I think the source of the problem was that MSBuild has a file path length restriction to 260 characters. This causes the basic compiler test CMake performs to build a project called CompilerIdCXX.vcxproj to fail with the error:

C1083: Cannot open source file: 'CMakeCXXCompilerId.cpp'

because the length of the file's path e.g.

C:\Users\spenc\Desktop\...\MyProjectDirectory\build\CMakeFiles\...\CMakeCXXCompilerId.cpp

exceeds the MAX_PATH restriction.

CMake then concludes there is no CXX compiler.


I ran into this issue while building libgit2-0.23.4. For me the problem was that C++ compiler & related packages were not installed with VS2015, therefore "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" file was missing and Cmake wasn't able to find the compiler.

I tried manually creating a C++ project in the Visual Studio 2015 GUI (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe) and while creating the project, I got a prompt to download the C++ & related packages.

After downloading required packages, I could see vcvarsall.bat & Cmake was able to find the compiler & executed successfully with following log:

C:\Users\aksmahaj\Documents\MyLab\fritzing\libgit2\build64>cmake ..
-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual        
Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual  
Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE)
-- Could NOT find ZLIB (missing:  ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- zlib was not found; using bundled 3rd-party sources.
-- LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of 
the default search path.
-- Looking for futimens
-- Looking for futimens - not found
-- Looking for qsort_r
-- Looking for qsort_r - not found
-- Looking for qsort_s
-- Looking for qsort_s - found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Found PythonInterp: C:/csvn/Python25/python.exe (found version "2.7.1")
-- Configuring done
-- Generating done
-- Build files have been written to:    
C:/Users/aksmahaj/Documents/MyLab/fritzing/libgit2/build64

I get exactly the reported error if ccache is enabled, when using CMake's Xcode generator. Disabling ccache fixed the problem for me. Below I present a fix/check that works for MacOS, but should work similarly on other platforms.

Apparently, it is possible to use CMake's Xcode generator (and others) also in combination with ccache, as is described here. But I never tried it out myself.

# 1) To check if ccache is enabled:
echo $CC
echo $CXX
# This prints something like the following: 
#     ccache clang -Qunused-arguments -fcolor-diagnostics. 
# CC or CXX are typically set in the `.bashrc` or `.zshrc` file.

# 2) To disable ccache, use the following:
CC=clang
CXX=clang++

# 3) Then regenerate the cmake project
cmake -G Xcode <path/to/CMakeLists.txt>

For me it worked to use the Developer Command Prompt that comes with Visual Studio and then just cd to your/jcef/dir and run cmake -G "Visual Studio 14 Win64" ..


Make sure you have selected the correct version of Visual Studio. This is trickier than it seems because Visual Studio 2015 is actually Visual Studio 14, and similarly Visual Studio 2012 is Visual Studio 11. I had incorrectly selected Visual Studio 15 which is actually Visual Studio 2017, when I had 2015 installed.


You can also make sure you are the sudo user and you have READ/WRITE access on the directory you are working. I had a similar problem on OS X, and I got it fixed just by entering in sudo mode.


I had the same issue with cmake-gui (No CMAKE_CXX_COMPILER could be found.), while running CMake from the command line worked fine. After manually adding the entries

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin

to the PATH environment variable it worked for me.


Just in case it helps any one like me in future:

I have had this issue for 24 hours now, on 3 different 64-bit machines(Win7 , Windows 8.1 VM and WIn 8.1 laptop) - whilst trying to build WebKit with VS 2017.

The simple issue here is that the VC++ compiler (i.e cl.exe and it's dependent DLLs) is not visible to CMake. Simple. By making the VC++ folders containing those binaries visible to CMake and your working command prompt(if you're running Cmake from a command prompt), voila! (In addition to key points raised by others , above)

Anyway, after all kinds of fixes - as posted on these many forums- I discovered that it was SIMPLY a matter of ensuring that the PATH variable's contents are not cluttered with multiple Visual Studio BIN paths etc; and instead, points to :

a) the location of your compiler (i.e. cl.exe for your preferred version of Visual Studio ), which in my case(targeting 64-bit platform, and developing on a 64-bit host) is: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64

b) and in addition, the folder containing a dependent DLL called (which cl.exe is dependent on): api-ms-win-crt-runtime-l1-1-0.dll - which on my machine is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Remote Debugger\x64

These two directories being added to a simplified and CUSTOM System Path variable(working under a Admin priviledged commmand prompt), eliminated my "No CMAKE_C_COMPILER could be found" and "No CMAKE_CXX_COMPILER could be found." errors.

Hope it helps someone.


For Ubuntu, please install the below things:

sudo apt-get update && sudo apt-get install build-essential

None of the solutions here solves my problem - only when I install Windows Update for universal C runtime.

Now CMake is working and no more link hangs from Visual Studio.

Update for Universal C Runtime in Windows


I had the same errors with CMake. In my case, I have used the wrong Visual Studio version in the initial CMake dialog where we have to select the Visual Studio compiler.

Then I changed it to "Visual Studio 11 2012" and things worked. (I have Visual Studio Ultimate 2012 version on my PC). In general, try to input an older version of Visual Studio version in the initial CMake configuration dialog.


Look in the Cmakelists.txt if you find ARM you need to install C++ for ARM

It's these packages:

C++ Universal Windows Platform for ARM64 "Not Required"

Visual C++ Compilers and libraries for ARM "Not Required"

Visual C++ Compilers and libraries for ARM64 "Very Likely Required"

Required for finding Threads on ARM 
enable_language(C) 
enable_language(CXX)

Then the problems

No CMAKE_C_COMPILER could be found.

No CMAKE_CXX_COMPILER could be found.

Might disappear unless you specify c compiler like clang, and maybe installing clang will work in other favour.

You can with optional remove in cmakelists.txt both with # before enable_language if you are not compiling for ARM.


I updated Visual Studio 2015 update 2 to Visual Studio 2015 update 3, and it solved my problem.


This works for me in Ubuntu 17.10 (Artful Aardvark):

apt-get update
apt-get install build-essential

I had the same problem.

I was trying to install dlib on my machine and it gave me this error. The tutorial mentioned in the question leads to downloading visual studio 2017. I solved this by uninstalling VS 2017 and installing VS 2015

One can install VS 2015 via this stackoverflow thread : How to download Visual Studio Community Edition 2015 (not 2017)


This happened to me after I installed Visual Studio 15 2017.

The C++ compiler for Visual Studio 14 2015 was not the problem. It seemed to be a problem with the Windows 10 SDK.

Adding the Windows 10 SDKs to Visual Studio 14 2015 solved the problem for me.

See attached screenshot.

Enter image description here


I know this question is about visual studio 2015. I faced this issue with visual studio 2017. When searched on google I landed to this page. After looking at first 2,3 answers I realized this is the problem with vc++ installation. Installing the workload "Desktop development with c++" resolved the issue.

Desktop development with c++


Examples related to c++

Method Call Chaining; returning a pointer vs a reference? How can I tell if an algorithm is efficient? Difference between opening a file in binary vs text How can compare-and-swap be used for a wait-free mutual exclusion for any shared data structure? Install Qt on Ubuntu #include errors detected in vscode Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio 2017 errors on standard headers How do I check if a Key is pressed on C++

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to gcc

Can't compile C program on a Mac after upgrade to Mojave Compiling an application for use in highly radioactive environments Make Error 127 when running trying to compile code How to Install gcc 5.3 with yum on CentOS 7.2? How does one set up the Visual Studio Code compiler/debugger to GCC? How do I set up CLion to compile and run? CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found How to printf a 64-bit integer as hex? Differences between arm64 and aarch64 Fatal error: iostream: No such file or directory in compiling C program using GCC

Examples related to cmake

Copy file from source directory to binary directory using CMake CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found Installing cmake with home-brew CMake does not find Visual C++ compiler What's the CMake syntax to set and use variables? How do I add a library path in cmake? How to build x86 and/or x64 on Windows from command line with CMAKE? Difference between using Makefile and CMake to compile the code Add external libraries to CMakeList.txt c++ Cmake is not able to find Python-libraries

Examples related to visual-studio-2015

How to download Visual Studio Community Edition 2015 (not 2017) The default XML namespace of the project must be the MSBuild XML namespace tsconfig.json: Build:No inputs were found in config file How to install Visual C++ Build tools? Could not load file or assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" How to unapply a migration in ASP.NET Core with EF Core The term "Add-Migration" is not recognized Visual Studio 2015 Update 3 Offline Installer (ISO) Getting "project" nuget configuration is invalid error ASP.NET 5 MVC: unable to connect to web server 'IIS Express'