我在这里完全不知所措。
我有一个使用 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
中——一个不存在的文件夹。
有人知道我可能忽略了哪个选项吗?我几乎什么都试过了。
最佳答案
我也遇到了“无法编译简单的测试程序”问题(Qt Creator、CMake)。在我的例子中,原因是 CMake 的路径包含禁止使用的字符:显然不允许使用空格和括号。卸载 CMake 并在 \ProgramFilesx86\CMake
下重新安装它为我解决了这个问题。
关于c++ - Cmake 拒绝找到正确的 MinGW 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16797925/