【问题标题】:How to set cmake CXX variable on windows如何在 Windows 上设置 cmake CXX 变量
【发布时间】:2015-10-16 06:33:54
【问题描述】:

我收到以下错误

正在运行:Microsoft Windows [版本 6.1.7601]

错误:

CMake Warning at CMakeLists.txt:4 (project):
  To use the NMake generator, cmake must be run from a shell that can use the
  compiler cl from the command line.  This environment does not contain
  INCLUDE, LIB, or LIBPATH, and these must be set for the cl compiler to
  work.


-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (project):
  The CMAKE_C_COMPILER:

    cl

  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 Error at CMakeLists.txt:4 (project):
  The CMAKE_CXX_COMPILER:

    cl

  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 "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!

如果有人可以帮忙...

【问题讨论】:

    标签: c++ windows cmake


    【解决方案1】:

    在运行 cmake 之前,您需要运行 Visual Studio 提供的批处理脚本来设置您的环境。它在X:\Visual\Studio\Dir\VC\vcvarsall.bat 下。在“Visual Studio 命令提示符”的开始菜单中还应该有一个快捷方式,它将打开一个提示符并自动运行vcvarsall.bat

    【讨论】:

    • w/vs2019 开始菜单项似乎是“VS 2019 的开发人员命令提示符”
    【解决方案2】:

    请注意,我通过将其添加到安装了 Visual Studio 2019 的 PATH 环境变量中解决了该问题:

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.20.27508\bin\Hostx64\x64
    

    【讨论】:

      【解决方案3】:

      尝试使用“Visual Studio 命令提示符”(vcvarsall.bat)

      【讨论】:

        【解决方案4】:

        正如其他人所说,您可以按照@Miles 所说的路径在“Visual Studio 命令提示符”中运行 cmake,或者(更好的方法)将 Visual Studio 编译器的路径添加到您的路径中。检查这条路径:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin 并在您的计算机中找到它,然后将其添加到您的 PATH 环境变量中。

        【讨论】:

        • 我认为我什至没有安装 Visual Studio :)。我试试这个,谢谢
        • 我安装了 Visual Studio 14.0 但文件不存在。在任何地方都找不到 vcvarsall。我想我会放弃这个,我已经尝试安装一个多星期了。我切换到ubuntu并在那里尝试。非常感谢所有回答的人
        • 检查此文件是否存在:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe 如果存在,您只需将其添加到您的 PATH 环境变量中。但是对于程序员来说,Linux 当然要容易得多:)
        • 不,不是我在bin里的exe文件是bscmake、cvtres、mspdbrsv、nmake、undname和xdcmake
        【解决方案5】:

        我遇到了同样的问题。我意识到 cl 没有随 Visual Studio 2015 一起提供,但是当我安装 2013 express 时,它可以工作。

        使用“Visual Studio 2013”​​->“Visual Studio 工具”->“VS2013 x64 Cross Tools 命令提示符”。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-03-11
          • 1970-01-01
          • 2011-08-16
          • 2022-10-15
          • 1970-01-01
          相关资源
          最近更新 更多