[英]CMake on Windows
我正在嘗試在 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:\Anaconda2\MinGW\x86_64-w64-mingw32\bin\gcc.exe
因為 CMake 的錯誤消息在這里具有誤導性,我認為它需要更詳細的答案。
簡而言之,您遇到了雞與蛋的問題。
CMake 的編譯器檢測功能強大,但由於 - 在第一次嘗試期間 -
-G
一起使用的顯式生成器PATH
環境中找不到任何 C/C++ 編譯器CC
環境變量它默認為nmake
。
現在問題來了:它確實記住了您在變量緩存中的隱式生成器/編譯器選擇(請參閱CMAKE_GENERATOR
中的CMakeCache.txt
)。 如果您安裝了多個編譯器,這是一個非常有用的功能。
但是,如果您隨后聲明CC
環境變量 - 正如錯誤消息所暗示的那樣 - 為時已晚,因為在第一次嘗試時記住了您的生成器的選擇。
我看到了兩種可能的方法:
cmake.exe -G "MinGW Makefiles" ..
(如@Guillaume 鏈接的答案所建議的) 給出正確的選項來cmake.exe -G "MinGW Makefiles" ..
生成器的選擇CMakeCache.txt
)並在將編譯器的bin
文件夾添加到PATH
環境后執行cmake.exe ..
。參考
我使用cmake -G "MinGW Makefiles" .
而不是cmake .
有效!
我遇到了同樣的問題,對我有用的是:
pip install dlib
部分和其余部分。C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\Hostx64\\x64
添加了這個路徑。添加環境變量路徑的方法也可以在上面的教程中找到。)你的cmake是如何安裝的? 如果您使用cygwin安裝它,現在嘗試cmake官方站點的最新Windows版本並設置PATH變量以確保使用正確的cmake版本。 它對我有用,希望它對你也有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.