在 PATH 中找不到 CLION 中的 GCC 编译器,因此无法编译简单的 C++ 程序
GCC compiler in CLION not found in PATH so cannot compile simple C++ program
当我尝试编译一个简单的 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.
我得到 CMAKE_CXX_COMPILER:
的相同消息块,引用文件 C:/cygwin64/bin/g++.exe
。
两个 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)
结果还是一样
已知 regression 在 CLion 2020.1 中将在即将发布的更新中修复。
作为解决方法,我从 CLion 的工具链设置页面中删除了自定义编译器路径。它检测到相同的编译器并且可以正常工作。
当我尝试编译一个简单的 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.
我得到 CMAKE_CXX_COMPILER:
的相同消息块,引用文件 C:/cygwin64/bin/g++.exe
。
两个 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)
结果还是一样
已知 regression 在 CLion 2020.1 中将在即将发布的更新中修复。
作为解决方法,我从 CLion 的工具链设置页面中删除了自定义编译器路径。它检测到相同的编译器并且可以正常工作。