0

我正在尝试使用 CMake 在 Windows 下使用 CodeBlocks 进行编码。

在 Cygwin 控制台中,我这样做:

cmake .. -G"CodeBlocks - Unix Makefiles"

输出是:

CMake Error: CMake was unable to find a build program corresponding to "Unix 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:D:/sources/tests/testOSG/build_CodeBlocks/CMakeFiles/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:D:/sources/tests/testOSG/build_CodeBlocks/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

我试图设置那些有问题的变量,但结果是一样的:

set CMAKE_MAKE_PROGRAM=C:/Progra~2/CodeBlocks/MinGW/bin/mingw32-make.exe
set CMAKE_C_COMPILER=C:/Progra~2/Microsoft Visual Studio 10.0/VC/bin/cl.exe
set CMAKE_CXX_COMPILER=C:/Progra~2/Microsoft Visual Studio 10.0/VC/bin/cl.exe

任何想法如何使它工作?

编辑:将路径添加到编译器会有所帮助,但仍然存在错误:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Defining WIN32 under Cygwin due to CMAKE_LEGACY_CYGWIN_WIN32
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe -- broken
CMake Error at /usr/share/cmake-2.8.9/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
  10.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /cygdrive/d/sources/tests/testOSG/build_CodeBlocks/CMakeFiles/CMakeTmp

  Run Build Command:C:/Program\ Files\
  (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe
  "cmTryCompileExec437970983/fast"

  C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make -f
  CMakeFiles/cmTryCompileExec437970983.dir/build.make
  CMakeFiles/cmTryCompileExec437970983.dir/build

  /usr/bin/sh: -c: line 0: Erreur de syntaxe près du symbole inattendu « (
  »

  /usr/bin/sh: -c: line 0: `C:/Program Files
  (x86)/CodeBlocks/MinGW/bin/mingw32-make -f
  CMakeFiles/cmTryCompileExec437970983.dir/build.make
  CMakeFiles/cmTryCompileExec437970983.dir/build'

  mingw32-make: *** [cmTryCompileExec437970983/fast] Error 1

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):

-- Configuring incomplete, errors occurred!
4

3 回答 3

2

也许您从“MinGW 安装管理器”安装了“基本设置”。由于它没有安装包名称为“mingw-gcc-g++”的 GNU C++ 编译器,因此您应该选择它的“bin”和“dev”并手动安装。这对我有用。

于 2014-02-10T09:49:51.040 回答
1

对我来说,以下工作:

下载了 codeblocks-17.12mingw-setup。

添加到 /MinGW/bin 的路径

提示:不要安装到有空格的路径

在我的情况下 C:\Program Files (x86)\CodeBlocks\MinGW\bin 不适用于某些项目。

当使用 c:\codeblocks... 他们工作

在 cmake 中使用“CodeBlocks - MinGW Makefiles”

然后打开 project.cbp

于 2018-06-09T22:46:50.957 回答
0

确保带有编译器的目录(MinGw-gcc.exe 或类似的东西)在 PATH 中,然后再次启动控制台并尝试再次运行 cmake。

于 2013-02-22T14:36:00.597 回答