我有一個簡單的C++測試項目,並寫下我的CMakeLists.txt文件如下;如何正確設置CMakeLists.txt文件?
cmake_minimum_required(VERSION 2.8)
set(CMAKE_C_COMPILER "C:/MinGW/bin/gcc")
set(CMAKE_CXX_COMPILER "C:/MinGW/bin/g++")
project(simpleTest)
add_executable(main main.cpp)
當我嘗試運行CMake的GUI的一套發生器MinGW的我收到以下錯誤信息:
The C compiler identification is GNU 4.6.1
The CXX compiler identification is GNU 4.6.1
Check for working C compiler: C:/MinGW/bin/gcc
CMake Error: your C compiler: "C:/MinGW/bin/gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Check for working C compiler: C:/MinGW/bin/gcc -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/MinGW/bin/gcc" 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:7 (project)
CMake Error: your C compiler: "C:/MinGW/bin/gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "C:/MinGW/bin/g++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
Configuring incomplete, errors occurred!
我在Windows 7 64位和我確認了CMD是什麼; G ++ --version給出G ++(GCC)4.6.1。
我在做什麼錯?
你是對的沒有在CMakeLists.txt中設置編譯器,但一再檢查編譯器安裝在我指定的地方。 – Amani 2013-02-24 16:03:10
您是否刪除了兩行並清除了cmake緩存?此外,我添加到我的答案,你應該嘗試設置環境變量,然後再調用cmake – 2013-02-24 16:15:24