简体   繁体   English

CLION 中的 GCC 编译器在 PATH 中找不到,因此无法编译简单的 C++ 程序

[英]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:当我尝试编译一个简单的main.cpp时,包括:

#include <iostream>

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

CLION tells me that: CLION 告诉我:

-- 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 .我得到了CMAKE_CXX_COMPILER:参考文件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.两个 MAKE 文件都存在于文件夹C:\cygwin64\bin中,此路径在 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:查看有关此类问题的其他问题,我检查了 CLION 中编译器的版本设置,我有:

在此处输入图像描述

And the MAKE settings are: MAKE 设置为:

在此处输入图像描述

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:CMakeLists.txt文件中,我还指定了:

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.但结果还是一样。

It's known regression in CLion 2020.1 which will be fixed in the upcoming update. CLion 2020.1 中的已知回归将在即将到来的更新中修复。

As Workaround I removed custom compiler path from Toolchains setting page in CLion.作为解决方法,我从 CLion 的工具链设置页面中删除了自定义编译器路径。 It detects the same compiler and it works.它检测到相同的编译器并且可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM