windows-7 - 在 Windows 上运行 CMake

标签 windows-7 build-process mingw cmake taglib

我目前正在尝试让 CMake 在我的 Windows 7(64 位)系统上运行。我要编译TagLib以便稍后与我正在开发的 Qt 应用程序一起使用。我想用 MinGW 编译它(而不是 this other question 中的 Visual C++)。

我下载安装程序 (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++)。

有人知道这是怎么回事吗?

解决方案:

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

最佳答案

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

cmake -G "MinGW Makefiles"

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

关于windows-7 - 在 Windows 上运行 CMake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4101456/

相关文章:

qt - 无法使用 MSVC 2010 x86 构建 qt5.2.1 静态

c++ - 是什么导致这个简单的 SDL 渲染循环中的帧速率卡顿?

c++ - 在 Windows 上更改 Qt 的计时器分辨率

Windows 7 上的 Java 7 64 位 : how to switch java versions

c++ - 在哪里可以找到 MinGW C 库中所有函数的列表?

c++ - 从 MinGW 链接到 MSVC DLL

c++ - 帮助为 Netbeans 安装 C++

linux - 如何在构建期间测量 CPU、内存和磁盘使用情况?

android - gradle如何执行一个ant构建文件

c++ - 预编译 header 在使用 Qt Creator/qmake/MinGw 的调试版本中不起作用