25

我需要一些帮助来用 cmake 编译这个项目。这是错误消息。

$ ./build_avida
-- Building for: NMake Makefiles
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.


CMake Error: CMake was unable to find a build program corresponding to "NMake Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:C:/Users/Desk/Dropbox/2012-2013/BCB504/AvidaProject/avidagit/avida/CMakeFiles/2.8.10.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:C:/Users/Desk/Dropbox/2012-2013/BCB504/AvidaProject/avidagit/avida/CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
make: *** No rule to make target `install'.  Stop.
4

4 回答 4

23

尝试安装gccand gcc-c++,因为 Cmake 可以顺利使用它们。

基于 RedHat

yum install gcc gcc-c++

基于 Debian/Ubuntu

apt-get install cmake gcc g++

然后,

  1. 删除“CMakeCache.txt”
  2. 再次运行编译。
于 2013-09-23T16:35:15.473 回答
10

即使我已经安装了 gcc,我也必须运行

sudo apt-get install build-essential

摆脱那个错误

于 2020-08-19T12:29:37.213 回答
6

我使用的方法是启动可以在“开始”菜单中找到的“Visual Studio 命令提示符”。例如,我的 Visual Studio 2010 Express 安装Visual Studio Command Prompt (2010)Start Menu\Programs\Microsoft Visual Studio 2010\Visual Studio Tools.

vcvarsall.bat此快捷方式通过调用从正确的 Visual Studio 安装中设置编译器、链接器等的脚本来准备环境。

或者,如果您已经打开了提示,您可以通过调用类似的脚本来准备环境:

:: For x86 (using the VS100COMNTOOLS env-var)
call "%VS100COMNTOOLS%"\..\..\VC\bin\vcvars32.bat

或者

:: For amd64 (using the full path)
call C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat

然而:

您的输出(带有“$”提示符)表明您正在尝试从 MSys shell 运行 CMake。在这种情况下,通过显式指定 makefile 生成器,为 MSys 或 MinGW 运行 CMake 可能会更好:

cmake -G"MSYS Makefiles"
cmake -G"MinGW Makefiles"

运行cmake --help以获取所有可能生成器的列表。

于 2013-02-11T08:45:19.287 回答
5

那些错误:

“CMake 错误:未设置 CMAKE_C_COMPILER,在 EnableLanguage 之后

CMake 错误:在 EnableLanguage 之后未设置 CMAKE_CXX_COMPILER”

表示你还没有安装 mingw32-base。

转到http://sourceforge.net/projects/mingw/files/latest/download?source=files

然后确保选择“mingw32-base”

确保在 PATH 部分正确设置环境变量。"C:\MinGW\bin"

之后打开 CMake 并选择安装 --> 删除缓存。

然后再次单击配置按钮。我就是这样解决问题的,希望你能解决问题。

于 2015-10-03T11:56:28.200 回答