【问题标题】:GCC compiler in CLION not found in PATH so cannot compile simple C++ program在 PATH 中找不到 CLION 中的 GCC 编译器,因此无法编译简单的 C++ 程序
【发布时间】:2020-08-12 20:01:09
【问题描述】:

当我尝试编译一个简单的main.cpp 时:

#include <iostream>

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

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.

对于引用文件 C:/cygwin64/bin/g++.exeCMAKE_CXX_COMPILER:,我收到了相同的消息块。

两个 MAKE 文件都存在于文件夹 C:\cygwin64\bin 中,此路径在 Windows 中称为环境变量。

查看有关此类问题的其他问题,我检查了 CLION 中编译器的版本设置,我有:

MAKE 设置为:

谁能告诉我这里缺少什么以便程序构建和运行?

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)

但结果还是一样。

【问题讨论】:

  • 你的机器上安装了cygwin吗?此外,如果 CLion 检测到 cygwin,则无需在 CMakeLists.txt 文件中指定 CMAKE_C_COMPILERCMAKE_CXX_COMPILER
  • 是的。 Cygwin 位于文件夹 C:\cygwin64\bin 中,并且为此也有一个环境变量。
  • 好的,那么也许你可以尝试删除CMakeLists.txt 文件中关于CMAKE_C_COMPILERCMAKE_CXX_COMPILER 的两行。
  • 执行此操作会在 CLION 中显示一条消息Cannot find any MAKE profile.
  • 在CMake选项卡中,您是否手动填写了其他参数,例如-DCMAKE_MAKE_PROGRAM

标签: c++ gcc build cmake clion


【解决方案1】:

在 CLion 2020.1 中已知 regression,将在即将到来的更新中修复。

作为解决方法,我从 CLion 的工具链设置页面中删除了自定义编译器路径。它检测到相同的编译器并且可以正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 1970-01-01
    • 1970-01-01
    • 2019-09-20
    • 1970-01-01
    相关资源
    最近更新 更多