Cmake拒绝找到正确的MinGW文件夹

时间:2013-05-28 17:21:11

标签: c++ qt compiler-construction cmake qt-creator

我在这里完全不知所措。

我有一个使用CMake的C ++项目。它曾经工作,但最近出现了一些奇怪的问题,所以我决定重新安装Qt SDK和CMake。但是,现在我在尝试构建文件时遇到以下错误:

CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe" is not able to
  compile a simple test program.

  It fails with the following output:

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


CMake Error: your C compiler: "C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe" was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "C:/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed

CMake Error: your C compiler: "C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe" was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name.-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe -- broken
-- Configuring incomplete, errors occurred!

这完全令我难以置信。 MinGW位于C:/Qt/Qt5.0.2/Tools/,而不是Qt5.0.1。我在CMakeLists.txt文件中这么说:

SET(CMAKE_C_COMPILER C:/Qt/Qt5.0.2/Tools/MinGW/bin/gcc)
SET(CMAKE_CXX_COMPILER C:/Qt/Qt5.0.2/Tools/MinGW/bing++)

我甚至将C:/Qt/Qt5.0.2/Tools/MinGW/bin/添加到全局PATH变量中,但这没有任何帮助。 CMake一直认为它应该在Qt5.0.1 - 一个不存在的文件夹中。

有人知道我可能会忽略哪些选项吗?我已经尝试了一切。

2 个答案:

答案 0 :(得分:0)

我还有“无法编译简单的测试程序”-issue(Qt Creator,CMake)。在我的情况下,原因是CMake的路径包含禁用的字符:显然不允许使用空格或括号。卸载CMake并在\ProgramFilesx86\CMake下重新安装它为我解决了这个问题。

答案 1 :(得分:-1)

我有同样的问题,我找到了答案。看起来好像Qt的ming有bug,所以你会得到像“gcc被打破”这样的错误。重新安装mingw http://www.mingw.org/并将gcc.exe,g ++。exe从C:\ MingW \ Bin \链接到你的CMake。再次构建并查看。

祝你好运!