首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >windows下CodeBlocks的CMake

windows下CodeBlocks的CMake
EN

Stack Overflow用户
提问于 2013-02-22 20:37:56
回答 3查看 9.7K关注 0票数 0

我正在尝试在Windows下使用CMake来编写CodeBlocks代码。

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

代码语言:javascript
复制
cmake .. -G"CodeBlocks - Unix Makefiles"

输出为:

代码语言:javascript
复制
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!

我尝试设置这些有问题的变量,但结果是相同的:

代码语言:javascript
复制
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

有什么办法让它工作吗?

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

代码语言:javascript
复制
-- 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!
EN

回答 3

Stack Overflow用户

发布于 2014-02-10 17:49:51

也许你是从“MinGW安装管理器”安装的“基本安装”。因为它没有安装名为‘mingw-gcc-g++’的GNU C++编译器,所以你应该选择它的'bin‘和'dev’并手动安装。这对我很有效。

票数 2
EN

Stack Overflow用户

发布于 2018-06-10 06:46:51

对我来说,以下内容很管用:

已下载代码块-17.12mingw-setup。

添加到/MinGW/bin的路径

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

在我的例子中,C:\Program Files (X86)\CodeBlocks在某些项目中不起作用。

使用c:\codeblock时...它们起作用了

在cmake中使用"CodeBlocks - MinGW生成文件“

然后打开project.cbp

票数 1
EN

Stack Overflow用户

发布于 2013-02-22 22:36:01

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15024419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档