2010-11-04 186 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