1. <small id='JPnqf'></small><noframes id='JPnqf'>

    <i id='JPnqf'><tr id='JPnqf'><dt id='JPnqf'><q id='JPnqf'><span id='JPnqf'><b id='JPnqf'><form id='JPnqf'><ins id='JPnqf'></ins><ul id='JPnqf'></ul><sub id='JPnqf'></sub></form><legend id='JPnqf'></legend><bdo id='JPnqf'><pre id='JPnqf'><center id='JPnqf'></center></pre></bdo></b><th id='JPnqf'></th></span></q></dt></tr></i><div id='JPnqf'><tfoot id='JPnqf'></tfoot><dl id='JPnqf'><fieldset id='JPnqf'></fieldset></dl></div>

  2. <tfoot id='JPnqf'></tfoot>
    1. <legend id='JPnqf'><style id='JPnqf'><dir id='JPnqf'><q id='JPnqf'></q></dir></style></legend>
        <bdo id='JPnqf'></bdo><ul id='JPnqf'></ul>

      Windows 上的 CMake

      CMake on Windows(Windows 上的 CMake)

        <tbody id='4yKnT'></tbody>
      <i id='4yKnT'><tr id='4yKnT'><dt id='4yKnT'><q id='4yKnT'><span id='4yKnT'><b id='4yKnT'><form id='4yKnT'><ins id='4yKnT'></ins><ul id='4yKnT'></ul><sub id='4yKnT'></sub></form><legend id='4yKnT'></legend><bdo id='4yKnT'><pre id='4yKnT'><center id='4yKnT'></center></pre></bdo></b><th id='4yKnT'></th></span></q></dt></tr></i><div id='4yKnT'><tfoot id='4yKnT'></tfoot><dl id='4yKnT'><fieldset id='4yKnT'></fieldset></dl></div>

            • <bdo id='4yKnT'></bdo><ul id='4yKnT'></ul>
              <tfoot id='4yKnT'></tfoot>

              <small id='4yKnT'></small><noframes id='4yKnT'>

            • <legend id='4yKnT'><style id='4yKnT'><dir id='4yKnT'><q id='4yKnT'></q></dir></style></legend>
              1. 本文介绍了Windows 上的 CMake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试在 Windows 上运行 CMake,但出现以下错误:

                I am trying to run CMake on Windows, and I get the following error:

                -- 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"环境变量!

                However my "CC" environment variable is set!

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

                推荐答案

                因为 CMake 的错误信息在这里具有误导性,我认为它值得更详细的答案.

                Because CMake's error message is misleading here, I think it warrants a little more detailed answer.

                简而言之,您遇到了鸡与蛋类型的问题.

                In short, you ran into a chicken-and-egg kind of a problem.

                CMake 的编译器检测是强大的,但是因为 - 在第一次尝试期间 -

                CMake's compiler detection is mighty, but since - during the first try -

                • 您没有提供任何显式生成器 与 -G
                • 一起使用
                • 找不到安装的 Visual Studio
                • 在您的 PATH 环境中找不到任何 C/C++ 编译器
                • 找不到用编译器的完整路径定义的CC环境变量
                • you didn't give any explicit generator to use with -G
                • it couldn't find a Visual Studio installed
                • it couldn't find any C/C++ compiler in your PATH environment
                • it couldn't find a CC environment variable defined with the full path to a compiler

                默认为nmake.

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

                Now here comes the problem: it does remember your implicit generator/compiler choice in it's variable cache (see CMAKE_GENERATOR in CMakeCache.txt). What is a very useful feature, if you have multiple compilers installed.

                但是如果您随后声明了 CC 环境变量 - 正如错误消息所暗示的那样 - 为时已晚,因为您的生成器的选择在第一次尝试时就被记住了.

                But if you then declare the CC environment variable - as the error message suggests - it's too late since your generator's choice was remembered in the first try.

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

                I see two possible ways out of this:

                1. 通过使用 cmake.exe -G "MinGW Makefiles" .. 给出正确的选项来否决生成器的选择(正如@Guillaume 所建议的答案所暗示的那样)
                2. 删除您项目的二进制输出目录(包括CMakeCache.txt)并在添加编译器的bin文件夹后执行cmake.exe ..到您的 PATH 环境.
                1. Overrule the generator choice by given the right one with cmake.exe -G "MinGW Makefiles" .. (as the answer linked by @Guillaume suggests)
                2. Delete your project's binary output directory (including CMakeCache.txt) and do cmake.exe .. after you added your compiler's bin folder to your PATH environment.

                参考资料

                • 在 Windows 上运行 CMake
                • CMake 中的默认生成器是什么窗户?
                • CMakeLists.txt:30 (project) 中的 CMake 错误:找不到 CMAKE_C_COMPILER
                • CMake:如何指定要使用的 Visual C++ 版本?

                这篇关于Windows 上的 CMake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                Delay Loading DLLs(延迟加载 DLL)
                Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                Loading a dll from a dll?(从 dll 加载 dll?)
                <legend id='4Nk28'><style id='4Nk28'><dir id='4Nk28'><q id='4Nk28'></q></dir></style></legend>

                <tfoot id='4Nk28'></tfoot>
                • <bdo id='4Nk28'></bdo><ul id='4Nk28'></ul>

                • <small id='4Nk28'></small><noframes id='4Nk28'>

                      <i id='4Nk28'><tr id='4Nk28'><dt id='4Nk28'><q id='4Nk28'><span id='4Nk28'><b id='4Nk28'><form id='4Nk28'><ins id='4Nk28'></ins><ul id='4Nk28'></ul><sub id='4Nk28'></sub></form><legend id='4Nk28'></legend><bdo id='4Nk28'><pre id='4Nk28'><center id='4Nk28'></center></pre></bdo></b><th id='4Nk28'></th></span></q></dt></tr></i><div id='4Nk28'><tfoot id='4Nk28'></tfoot><dl id='4Nk28'><fieldset id='4Nk28'></fieldset></dl></div>
                            <tbody id='4Nk28'></tbody>