4

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?

Startec
  • 12,496
  • 23
  • 93
  • 160
  • The error "No CMAKE_CXX_COMPILER could be found." usually unrelated to the project itself and means that some settings are wrong. The are a number of questions on Stack Overflow about such error. Have you checked them? E.g., [that answer](https://stackoverflow.com/a/32830625/3440745) contains a lot of information about debugging such kind of errors. – Tsyvarev Jan 16 '19 at 07:52
  • Yes. I have tried every example there. – Startec Mar 11 '19 at 22:34
  • What about **additional information**, which is described in that answer? What is content of `CMakeFiles\CMakeError.log`? BTW, on the image I see "No CMAKE_**C** \_COMPILER could be found", but your textual description and the title is about CMAKE_ **CXX** _COMPILER. – Tsyvarev Mar 12 '19 at 08:33
  • 1
    Did you install a C++ compiler with your Visual Studio 2017? – rubenvb Jan 15 '20 at 14:30

3 Answers3

1

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.

Bowie Owens
  • 2,798
  • 23
  • 20
1

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
user175291
  • 11
  • 1
0

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.

Ate Somebits
  • 287
  • 1
  • 18