2010-11-04 183 views
56

我目前正試圖讓CMake在我的Windows 7(64位)系統上運行。我想編譯TagLib以備將來與我正在使用的Qt應用程序一起使用。我想用MinGW(不是Visual C++,如this other question)編譯它。在Windows上運行CMake

我下載安裝程序(cmake-2.8.3-win32-x86.exe)並安裝它(我也選擇將CMake添加到我的路徑中)。然後我到CMakeLists.txt文件的目錄並運行cmake .。然後它給了我這個巨大的錯誤。

C:\Users\Joel\Downloads\taglib-1.6.3>cmake . 
CMake Warning at CMakeLists.txt:1 (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 Warning at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake: 
28 (ENABLE_LANGUAGE): 
    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. 
Call Stack (most recent call first): 
    C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:60 (INCLUDE) 
    CMakeLists.txt:1 (project) 


CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found. Please set CMAKE_RC_COM 
PILER to a valid compiler path or name. 
-- Check for CL compiler version 
-- Check for CL compiler version - failed 
-- Check if this is a free VC compiler 
-- Check if this is a free VC compiler - yes 
-- Using FREE VC TOOLS, NO DEBUG available 
-- Check for working C compiler: cl 
CMake Warning at CMakeLists.txt:2 (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. 


CMake Warning at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake: 
28 (ENABLE_LANGUAGE): 
    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. 
Call Stack (most recent call first): 
    C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:60 (INCLUDE) 
    CMakeLists.txt:2 (PROJECT) 


CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeRCInformation.cmake:22 
(GET_FILENAME_COMPONENT): 
    get_filename_component called with incorrect number of arguments 
Call Stack (most recent call first): 
    C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:28 (ENABLE_LANG 
UAGE) 
    C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:60 (INCLUDE) 
    CMakeLists.txt:2 (PROJECT) 


CMake Error: CMAKE_RC_COMPILER not set, after EnableLanguage 
CMake Error: your C compiler: "cl" was not found. Please set CMAKE_C_COMPILER to a valid compiler 
path or name. 
CMake Error: Internal CMake error, TryCompile configure of cmake failed 
-- Check for working C compiler: cl -- broken 
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 
(MESSAGE): 
    The C compiler "cl" is not able to compile a simple test program. 

    It fails with the following output: 





    CMake will not be able to correctly generate this project. 
Call Stack (most recent call first): 
    CMakeLists.txt:1 (project) 


CMake Error: your C compiler: "cl" was not found. Please set CMAKE_C_COMPILER to a valid compiler 
path or name. 
CMake Error: your CXX compiler: "cl" was not found. Please set CMAKE_CXX_COMPILER to a valid compi 
ler path or name. 
-- Configuring incomplete, errors occurred! 

C:\Users\Joel\Downloads\taglib-1.6.3> 

我是那種驚訝的是,它沒有這麼難開箱即用,考慮到它標榜自己是一個跨平臺的補充。我試着設置INCLUDE,LIB和LIBPATH(Windows環境變量)到我的MinGW二進制文件目錄(C:\ MinGW \ bin),但它仍然給我同樣的錯誤。我也嘗試將CMAKE_C_COMPILER和CMAKE_CXX_COMPILER設置爲g ++的位置(C:\ MinGW \ bin \ g ++)。

有人知道這裏發生了什麼嗎?

SOLUTION:

每Tibur酒店的建議下,我跑了cmake的GUI創建make文件。 然後我進入目錄taglib目錄並運行mingw32-make.exe來完成實際構建。

回答

82

Windows的默認生成器似乎設置爲NMake。嘗試使用:

cmake -G "MinGW Makefiles" 

或者使用GUI,然後選擇MinGW的Makefile文件提示時發電機。不要忘記清理試圖運行cmake的目錄,或刪除GUI上的緩存。否則,它會與NMake再次嘗試。

+1

這樣做了。謝謝您的幫助! – 2010-11-04 23:15:44

+10

下一步是運行'mingw32-make.exe all'來完成實際的構建。 – 2012-11-16 20:33:15

+1

+1我錯過了'mingw32-make.exe',並被一個神祕的No Sane CXX編譯器迎接。 Gnu Make for Windows不會削減它,MinGW版本是必需的。 – Vorac 2014-06-16 17:45:56

13

VisualStudio安裝目錄中有一個vcvars32.bat。您可以在該批處理程序的末尾添加調用cmd.exe並啓動它。從那個shell中你可以使用cmake或者cmake-gui,並且cl.exe將被稱爲cmake

+0

要將代碼添加到vcvars32/64.bat中的cmd.exe調用中:「@call」cmd.exe 「' – NumesSanguis 2017-02-06 08:25:41