Startec
Startec

Reputation: 13216

CMAKE: "No CMAKE_CXX_COMPILER could be found."

I have a simple project where the file structure looks like this:

- CMakeLists.txt
- main.cpp

The CMakeLists.txtlooks like this:

# Project initialization
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
add_executable(Tutorial main.cpp)

When I run the Cmake GUI I get:

CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_CXX_COMPILER could be found.

enter image description here

I have Microsoft Visual Studio 2017 installed. I have compiled and run apps from it. The basic example from the CMAKE tutorial does not work.

Can anyone tell me why?

Upvotes: 9

Views: 23546

Answers (4)

shadowy figure
shadowy figure

Reputation: 21

I have spent a week trying to fix this error on windows and what I have found was that i have uninstalled windows SDK tools and then when I install it again the error has gone

download the windows SDK tools windows sdk download

Upvotes: 1

user175291
user175291

Reputation: 111

saw the same error -- Detecting C compile features - done CMake Error at CMakeLists.txt:4 (PROJECT): No CMAKE_CXX_COMPILER could be found.

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!

apt update
apt install build-essential

Upvotes: 11

Ate Somebits
Ate Somebits

Reputation: 321

Use the integrated Visual Studio CMAKE.

The error reporting in the VS build/output/error window has become somewhat complex, and many errors are delegated between the toolchains, etc. (i.e. the whole VS has become modularized lately)

Universal truth: log files are your best friend.

In my case, CMakeError.log has been constantly complaining it can't find kernel32.lib

Guess what? I forgot to install Windows SDK.

Basically, for any serious work, you need at least MSVS and Windows SDK, if you want to build for Windows. (Windows SDK is also now known as "Windows Kits", which is what you'll get in the StartMenu).

Essentially, your problem might simply be you don't have proper dev libs installed.

Upvotes: 1

Bowie Owens
Bowie Owens

Reputation: 2986

I'm not sure what is going wrong but you might want to take a look at:

https://learn.microsoft.com/en-us/cpp/ide/cmake-tools-for-visual-cpp?view=vs-2017

Visual Studio 2017 is able to open cmake files directly (should do the generator step for you behind the scenes) which may avoid the problem you have.

Upvotes: 1

Related Questions