4

OS X プラットフォームで実行configureするcmake-guiと、次のエラーが発生します。

The C compiler identification is GNU
The CXX compiler identification is GNU
Checking whether C compiler has -isysroot
Checking whether C compiler has -isysroot - yes
Checking whether C compiler supports OSX deployment target flag
Checking whether C compiler supports OSX deployment target flag - yes
Check for working C compiler: /usr/bin/gcc-4.0
Check for working C compiler: /usr/bin/gcc-4.0 -- broken
CMake Error at /Applications/CMake 2.8-2.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "/usr/bin/gcc-4.0" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp

  Run Build Command:/opt/local/bin/gmake "cmTryCompileExec/fast"

  /opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make
  CMakeFiles/cmTryCompileExec.dir/build

  gmake[1]: Entering directory
  `/Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp'

  "/Applications/CMake 2.8-2.app/Contents/bin/cmake" -E cmake_progress_report
  /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o

  /usr/bin/gcc-4.0 -isysroot -o
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c
  /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp/testCCompiler.c

  i686-apple-darwin10-gcc-4.0.1:
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o: No such file or
  directory

    <snip>

インターネット上のフォーラムなどを見て、これは PATH 変数に関係している可能性があることを確認しました。分析用の PATH 変数は次のとおりです。

! echo $PATH
/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/sw/bin:/sw/sbin:/Applications/MATLAB_R2012a.app/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin

このパス変数は、私が Python を構成したときに最近変更されました。GCC の問題も同じ時期に発生したに違いないと思います。これが発生するためにシステムのインストールに問題がある可能性はありますか?


いくつかの詳細。で指定されたビルド プログラムCMAKE_MAKE_PROGRAMは です/opt/local/bin/gmake

Configureまた、これらのエラーは で実行している場合にのみスローされることも発見しましたcmake-gui。コマンド ライン (cmake ..ビルド フォルダーから実行) では、構成は正常に完了します。

! cmake ..
-- The C compiler identification is GNU 4.0.1
-- The CXX compiler identification is GNU 4.2.1
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc-4.0
-- Check for working C compiler: /usr/bin/gcc-4.0 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done

ただし、一部のライブラリを使用すると、コンパイルが常に成功するとは限りません。たとえば、私がここで尋ねたこの質問を参照してください。したがって、その過程でまだ何かがうまくいかない可能性があると思いcmakeます。

4

2 に答える 2

3

解決策につながる可能性がある、質問に関するいくつかの観察...

CMake のバージョンに関する限り、かなり古い CMake 2.8.2 を使用しています。2.8.11 または今後の 2.8.12 のリリース候補を試して、問題がまだ存在するかどうかを確認してください。他に何もない場合は、おそらくより良いエラー メッセージが表示されるでしょう。

この質問と回答とそのリンクを参照しPATHて、Mac でコマンド ライン環境と他の手段で起動された GUI アプリケーションとの間で一貫した値を保証するさまざまな方法について確認してください。OS X でグローバル PATH 環境変数を設定するにはどうすればよいですか?

CMake GUI は、open コマンドを使用してターミナルから起動しない限り、ターミナルに表示されるものと同じ PATH 値を継承するとは限りません。

GCC 4.0 は C コンパイラですが、g++ 4.2 は C++ コンパイラです。なぜそれらは異なるのですか?

また、CMAKE_MAKE_PROGRAMを指し/opt/local/bin/gmakeます。両方のビルド ツリーに当てはまりますか? (コマンドラインのものと GUI のもの?) CMake が から C および C++ コンパイラを選択する/usr/binのに、gmake は/opt/local/bin...

コマンドライン環境は、これらのパスからこれらのツールを正確に使用するように注意深く設定されていますか? それとも、これも意外ですか?

使用している Xcode ツールのバージョンについてはまったく言及していません。おそらく、あなたの質問にそれを追加すると、より良い答えが誰かの脳に飛び込むのに役立ちます.

最後の観察: PATH には多くのものがあります。ビルド環境で使用する PATH 値を最小限に抑えることは、このような問題を回避するのに大いに役立ちます。少なくともソフトウェア構築環境では、これを必要最小限に抑えることを心からお勧めします。

回答のない回答で申し訳ありませんが、これほど多くのコメントは、スタック オーバーフローのコメントには少し過剰に思えました... :-)

于 2013-09-09T20:46:09.070 に答える