我正在尝试使用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!
答案 0 :(得分:2)
也许你从'MinGW Installation Manager'安装了'基本设置'。因为它没有安装包含名称为'mingw-gcc-g ++'的GNU C ++编译器,所以你应该选择它的'bin'和'dev'并手动安装。这对我有用。
答案 1 :(得分:1)
对我来说工作:
下载了codeblocks-17.12mingw-setup。
添加了/ MinGW / bin的路径
提示:不要安装在其中的空间
在我的情况下C:\ Program Files(x86)\ CodeBlocks \ MinGW \ bin不适用于某些项目。
使用c:\ codeblocks时......工作
在cmake中使用" CodeBlocks - MinGW Makefiles"
然后打开project.cbp
答案 2 :(得分:0)
确保带有编译器的目录(MinGw-gcc.exe或类似的东西)在PATH中,然后再启动控制台并尝试再次运行cmake。