【发布时间】:2019-08-28 19:17:28
【问题描述】:
我正在尝试使用 cmake 构建一个 c++ 项目。我在 Windows 上使用崇高的文本。这是我的 CMakeLists.txt 配置:
project(Arena)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_COMPILER C:\MinGW\bin)
set(CMAKE_CXX_COMPILER C:\MinGW\bin)
当我运行cmake . 命令时,我收到以下错误消息:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:1 (project):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
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 Error at CMakeLists.txt:1 (project):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
错误信息说没有找到cl编译器,这是因为我没有安装它。但我已经安装了 MINGW GNU 编译器集合 (GCC)。这些在我的PATHC:\MinGW\bin。如何配置 cmake 以使用我机器上已有的编译器进行编译?
愚蠢的问题警报:我也很困惑为什么错误消息是在谈论 NMake generator with Visual C++,因为我没有使用 Visual Studio?
尝试 1:
像cmake . -G "MinGW Makefiles"这样运行cmake命令,得到以下错误:
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
【问题讨论】:
-
你也应该发布你的 CMakeLists.txt 配置。
-
检查我更新的问题@Romen。
-
我认为您的系统 PATH 环境变量中没有 mingw 二进制文件。
-
当我运行命令
echo %PATH%时,我C:\MinGW\bin;存储二进制文件的元素之一,对 @drescherjm? -
应该没错,那个文件夹里有make程序吗?