CMake在Windows XP上无法工作。

8

我刚开始接触cmake,刚刚安装了它并且正在按照这篇文章操作:

http://www.cs.swarthmore.edu/~adanner/tips/cmake.php

D:\Works\c\cmake\build>cmake ..
-- Building for: NMake Makefiles
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.


-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Warning at D:/Tools/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:32 (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):
  D:/Tools/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:58 (INCLUDE)
  CMakeLists.txt:2 (project)


CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found.   Please set CMAKE_RC_COMPILER 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 D:/Tools/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:32 (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):
  D:/Tools/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:58 (INCLUDE)
  CMakeLists.txt:2 (PROJECT)


CMake Error at D:/Tools/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):
  D:/Tools/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-cl.cmake:32 (ENABLE_LANGUAGE)
  D:/Tools/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:58 (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 D:/Tools/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:2 (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 compiler path or name.
-- Configuring incomplete, errors occurred!

如何在Windows XP中成功使用cmake,您需要满足以下要求:已经在D:\Tools\Microsoft Visual Studio 9.0下安装了Visual Studio。


现在为.NET构建DSL语言有更好的选择,比如一个叫做FAKE的库。 - Tuomas Hietanen
2个回答

8
首先,我必须承认我不了解cmake。
为了使用NMake生成器,必须从能够使用命令行编译器cl的shell中运行cmake。这个环境不包含INCLUDE、LIB或LIBPATH,必须设置这些变量才能让cl编译器正常工作。
上述错误意味着cmake无法找到正确的C/C++编译器头文件和库文件的位置。
尝试从Visual Studio 2008命令提示符而不是命令提示符中运行cmake。你可以在“开始菜单 > 程序 > Microsoft Visual Studio 2008 > Visual Studio工具”下找到它,或者在文件夹*Microsoft Visual Studio 9.0\VC*中找到vcvarsall.bat。Visual Studio 2008命令提示符应该会自动为您设置所有这些环境变量,以便cmake知道在哪里找到它需要的必要文件。
命令提示符将在您的Visual Studio文件夹中启动,因此您需要键入以下命令来切换到源文件夹并启动cmake。
D:
cd D:\Works\c\cmake\build>
cmake

我希望这能对您有所帮助。

0

我在Win7上遇到了类似的问题,出现了同样的错误- C编译器“cl.exe”无法编译简单的测试程序。

对我有用的解决方案:

  1. 在Windows上不要在cygwin终端上运行cmake。

  2. 从命令提示符中运行它,并确保您拥有管理员权限,在Windows 7中,您可以通过转到“开始”->“所有程序”->“附件”->(右键单击命令提示符)并选择“以管理员身份运行”来启动命令提示符

然后运行'cmake <your source>'对我很管用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接