Search code examples
c++gccbuildcmakeclion

GCC compiler in CLION not found in PATH so cannot compile simple C++ program


When I try to compile a simple main.cpp consisting of:

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

CLION tells me that:

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_C_COMPILER:

    C:/cygwin64/bin/gcc.exe

  is not a full path and was not found in the PATH.

  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.

I get the same block of messages for the CMAKE_CXX_COMPILER: referring to file C:/cygwin64/bin/g++.exe.

Both MAKE files exist in folder C:\cygwin64\bin and this path is referred to as an environment variable in Windows.

Looking at other questions posted concerning this kind of problem, I have checked the version settings of the compiler in CLION and I have:

enter image description here

And the MAKE settings are:

enter image description here

Can anyone please advise what I am missing here in order for the program to build and run?

In the CMakeLists.txt file I have also specified:

cmake_minimum_required(VERSION 3.16)
project(HelloWorld1)

set(CMAKE_C_COMPILER C:\cygwin64\bin)
set(CMAKE_CXX_COMPILER C:\cygwin64\bin)

add_executable(HelloWorld1 main.cpp)

But the result is still the same.


Solution

  • It's known regression in CLion 2020.1 which will be fixed in the upcoming update.

    As Workaround I removed custom compiler path from Toolchains setting page in CLion. It detects the same compiler and it works.