如何安装Cmake C编译器和CXX编译器

Swi*_*Run 13 cmake

我需要一些帮助,用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.
Run Code Online (Sandbox Code Playgroud)

小智 19

尝试安装gccgcc-c++,因为CMake的工作顺利它们.

基于红帽

yum install gcc gcc-c++
Run Code Online (Sandbox Code Playgroud)

- 基于Ubuntu是Debian /

apt-get install cmake gcc g++
Run Code Online (Sandbox Code Playgroud)

然后,

  1. 删除'CMakeCache.txt'
  2. 再次运行编译.

  • 删除CMakeCache.txt就可以了.非常感谢! (3认同)

Vic*_*yew 7

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

sudo apt-get install build-essential
Run Code Online (Sandbox Code Playgroud)

摆脱那个错误


And*_*dré 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
Run Code Online (Sandbox Code Playgroud)

或者

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

然而:

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

cmake -G"MSYS Makefiles"
cmake -G"MinGW Makefiles"
Run Code Online (Sandbox Code Playgroud)

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


Ahm*_*vli 5

这些错误:

“CMake 错误:启用语言后未设置 CMAKE_C_COMPILER

CMake 错误:启用语言后未设置 CMAKE_CXX_COMPILER”

说明你还没有安装 mingw32-base。

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

然后确保选择“mingw32-base”

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

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

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

  • 即使安装了编译器,您也可能在 Linux 计算机上收到此错误。 (8认同)
  • @cauchy,那么你提到的这个问题如何解决? (2认同)