gpt4 book ai didi

c++ - 为什么 cmake 找不到编译器 cl

转载 作者:行者123 更新时间:2023-11-30 02:25:05 27 4
gpt4 key购买 nike

我正在尝试将一组可执行文件安装到运行 Windows 10 的计算机上,下载它们的源代码后,我需要使用 cmake 编译它们。我下载了最新版本的 cmake,并且(在设置了正确的工作目录之后)一直在尝试在 Windows 命令提示符下运行以下命令以安装可执行文件:

mkdir build
cd build
cmake ../
make

但是,cmake 命令始终会产生以下错误,并且无法生成 make 命令可以利用的任何类型的 make 文件:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (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:2 (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.


-- Configuring incomplete, errors occurred!
See also "C:/Users/Hannah/Documents/nupack3.2.0/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Hannah/Documents/nupack3.2.0/build/CMakeFiles/CMakeError.log".

我已经尝试了很多让 cmake 工作的解决方案,但都没有奏效。我试图将我的 cmake 文件夹的 bin 添加到我的 PATH 环境变量,我试图重新安装我的 cmake 拷贝,并尝试使用 CMake GUI 来生成 make 文件( Running CMake on Windows ),甚至下载 Visual Studio ( How to set cmake CXX variable on windows ),但是因为我没有足够的使用 CMake GUI 或 Visual Studio 的经验,或者因为还有其他问题,所以似乎没有任何效果,cmake ../ 产生完全相同的错误。

任何人都可以为我提供一些替代解决方案来使这个命令起作用吗?

最佳答案

after having downloaded their binaries, I need to compile them using cmake

这毫无意义。要么您下载了源代码并需要编译它们,要么您下载了二进制文件并且不需要编译其他任何东西。

如果发现需要编译,则必须安装编译器(例如 Visual Studio)。安装 VS 后,CMake 应该可以轻松找到它(使用 VS 生成器时)。

然而,您的错误消息似乎表明使用了 NMake 生成器,它需要从为构建正确配置的命令提示符下运行。安装 Visual Studio 时,开始菜单中应该有开发命令提示符的快捷方式。为您的平台启动正确的一个并从那里运行 CMake。

关于c++ - 为什么 cmake 找不到编译器 cl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44828842/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com