【发布时间】: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++.exe 的 CMAKE_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_COMPILER和CMAKE_CXX_COMPILER。 -
是的。 Cygwin 位于文件夹
C:\cygwin64\bin中,并且为此也有一个环境变量。 -
好的,那么也许你可以尝试删除
CMakeLists.txt文件中关于CMAKE_C_COMPILER和CMAKE_CXX_COMPILER的两行。 -
执行此操作会在 CLION 中显示一条消息
Cannot find any MAKE profile. -
在CMake选项卡中,您是否手动填写了其他参数,例如
-DCMAKE_MAKE_PROGRAM?