2

単純なC++テストプロジェクトがあり、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!

私はWindows764ビットを使用しており、cmdでそれを確認しました。G ++ --versionは、G ++(GCC)4.6.1を提供します。

私は何が間違っているのですか?

4

2 に答える 2

3

申し訳ありませんが、これは指定した場所にコンパイラがインストールされていないようです。また、CMakeLists.txtでコンパイラを設定しない理由もここで確認してください。

したがって、これらを削除し、cmakeキャッシュをクリアし、CMakeを呼び出す前に環境変数CCとCXXを設定して、再試行します。

于 2013-02-24T15:50:17.193 に答える
1

あなたの問題はパス文字列にあると思います。これを試して:

set(CMAKE_C_COMPILER "C:\\MinGW\\bin\\gcc")
set(CMAKE_CXX_COMPILER "C:\\MinGW\\bin\\g++")

または、CMakeGUIでコンパイラを設定することもできます。[生成]をクリックした後、[ネイティブコンパイラを指定する]オプションを選択し、正しい場所を設定または参照します。

于 2013-02-26T12:16:49.640 に答える