CMAKE: "No CMAKE_CXX_COMPILER could be found."
Asked Answered
N

4

8

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?

Nobukonoby answered 16/1, 2019 at 2:12 Comment(4)
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 contains a lot of information about debugging such kind of errors.Element
Yes. I have tried every example there.Nobukonoby
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.Element
Did you install a C++ compiler with your Visual Studio 2017?Lakesha
M
9

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
Moluccas answered 8/5, 2023 at 7:2 Comment(0)
P
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.

Podesta answered 16/1, 2019 at 3:45 Comment(0)
C
1

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.

Covered answered 15/1, 2020 at 14:11 Comment(1)
You make my day!Coalfield
N
0

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

Neckerchief answered 20/9 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.