在 Windows 上运行 CMake [英] Running CMake on Windows

查看:35
本文介绍了在 Windows 上运行 CMake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试让 CMake 在我的 Windows 7(64 位)系统上运行.我想编译 TagLib 以便以后与我正在开发的 Qt 应用程序一起使用.我想用 MinGW 编译它(不是像 这个其他问题).

I am currently trying to get CMake to run on my Windows 7 (64-bit) system. I want to compile TagLib for later use with a Qt application I am working on. I would like to compile it with MinGW (not Visual C++ as in this other question).

我下载安装程序 (cmake-2.8.3-win32-x86.exe) 并安装它(我也选择将 CMake 添加到我的路径中).然后我转到 CMakeLists.txt 文件所在的目录并运行 cmake ..然后它给了我这个巨大的错误.

I download the installer (cmake-2.8.3-win32-x86.exe) and install it (I also opt to add CMake to my path). I then go to the directory why the CMakeLists.txt file is and run cmake .. It then gives me this giant error.

C:UsersJoelDownloads	aglib-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:UsersJoelDownloads	aglib-1.6.3>

我有点惊讶它开箱即用的失败,因为它标榜自己是一个跨平台的品牌.

I was kind of surprised that it failed so hard out of the box, considering it advertises itself as a cross-platform make.

我尝试将 INCLUDE、LIB 和 LIBPATH(Windows 环境变量)全部设置到我的 MinGW 二进制文件目录 (C:MinGWin) 中,但它仍然给我同样的错误.我还尝试将 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 设置为 g++ 的位置(C:MinGWing++).

I tried setting INCLUDE, LIB, and LIBPATH (Windows environment variables) all to my MinGW binaries directory (C:MinGWin) but it's still giving me the same error. I also tried setting CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to the location of g++ (C:MinGWing++).

有人知道这里发生了什么吗?

Does anyone know what's going on here?

解决方案:

根据 tibur 的建议,我运行了 cmake GUI 来创建 make 文件.然后我进入目录 taglib 目录并运行 mingw32-make.exe 来做实际的构建.

Per tibur's suggestion, I ran the cmake GUI to create the make files. I then went into the directory taglib directory and ran mingw32-make.exe to do the actual build.

推荐答案

Windows 的默认生成器似乎设置为 NMAKE.尝试使用:

The default generator for Windows seems to be set to NMAKE. Try to use:

cmake -G "MinGW Makefiles"

或者使用 GUI,并在提示输入生成器时选择 MinGW Makefiles.不要忘记清理您尝试运行 CMake 的目录,或删除 GUI 中的缓存.否则,它将使用 NMAKE 重试.

Or use the GUI, and select MinGW Makefiles when prompted for a generator. Don't forget to cleanup the directory where you tried to run CMake, or delete the cache in the GUI. Otherwise, it will try again with NMAKE.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆