c/c++语言开发共享在Windows上进行CMake

我试图在Windows上运行CMake,我收到以下错误:

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

但是设置了我的“CC”环境变量!

 >>echo %CC% C:Anaconda2MinGWx86_64-w64-mingw32bingcc.exe 

    由于CMake的错误信息在这里有误导性,我认为这需要更详细的答案。

    简而言之,你遇到了一个鸡蛋和鸡蛋的问题。

    CMake的编译器检测很强大,但是从第一次尝试开始 –

    它是默认的nmake

    现在出现了问题:它确实记住了它的变量缓存中的隐式生成器/编译器选择(请参阅CMAKE_GENERATOR中的CMakeCache.txt )。 如果您安装了多个编译器,那么这是一个非常有用的function。

    但是如果你然后声明CC环境变量 – 正如错误消息所暗示的那样 – 那么为时已晚,因为你的选择器在第一次尝试中被记住了。

    我看到了两种可能的方法:

    参考

    你的cmake是如何安装的? 如果你使用cygwin安装它,现在尝试cmake官方网站的最新windows版本并设置PATH变量以确保使用正确的cmake版本。 它对我有用,希望它对你也有帮助。

      以上就是c/c++开发分享在Windows上进行CMake相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/560661.html

      (0)
      上一篇 2021年1月28日
      下一篇 2021年1月28日

      精彩推荐