2017-10-21 14 views
-3

Ubuntu 16.04にgcc-4.8をインストールしてC++ 11プログラムをビルドしました。私はCMakeList.txtファイルをOS XでClangとGCC 4.8がMacportsから構築してうまく動作しています。gcc-4.8はテストプログラムをコンパイルできませんか?

私はCXX=/usr/bin/gcc-4.8を設定することにより開始し、その後、CMakeのが次のエラーで失敗します。

再び
-- The C compiler identification is GNU 5.4.0 
-- The CXX compiler identification is unknown 
-- Check for working C compiler: /usr/bin/cc 
-- Check for working C compiler: /usr/bin/cc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Detecting C compile features 
-- Detecting C compile features - done 
-- Check for working CXX compiler: /usr/bin/gcc-4.8 
-- Check for working CXX compiler: /usr/bin/gcc-4.8 -- broken 
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message): 
    The C++ compiler "/usr/bin/gcc-4.8" is not able to compile a simple test 
    program. 

    It fails with the following output: 

    Change Dir: /home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp   

    Run Build Command:"/usr/bin/make" "cmTC_5df0c/fast" 

    /usr/bin/make -f CMakeFiles/cmTC_5df0c.dir/build.make 
    CMakeFiles/cmTC_5df0c.dir/build 

    make[1]: Entering directory 
    '/home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp' 

    Building CXX object CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o 

    /usr/bin/gcc-4.8 -o CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o -c 
    /home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp/testCXXCompiler.cxx 

    gcc-4.8: error trying to exec 'cc1plus': execvp: No such file or directory 

    CMakeFiles/cmTC_5df0c.dir/build.make:65: recipe for target 
    'CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o' failed 

    make[1]: *** [CMakeFiles/cmTC_5df0c.dir/testCXXCompiler.cxx.o] Error 1 

    make[1]: Leaving directory 
    '/home/ruipacheco/databaseclient/cpp/ninja/CMakeFiles/CMakeTmp' 

    Makefile:126: recipe for target 'cmTC_5df0c/fast' failed 

    make: *** [cmTC_5df0c/fast] Error 2 

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

-- Configuring incomplete, errors occurred! 

、私はgcc-4.8は、C++ 11個のプログラムを構築することが可能であり、私はこのCMakeLists.txtファイルを動作させるために管理している知っていますOSX上でgcc 4.8を使用すると、何が失われる可能性がありますか?

+0

多分正規表現サポートですか? –

+0

バージョン5より前のC++ 11のサポートはまだ不完全でした。あなたがそのような古いバージョン(これは7以上になっています)を決めた理由は何ですか? –

+0

あなたの質問を[編集]して[mcve]を提供してください。 –

答えて

3

"gcc-4.8"はC++コンパイラではなく、Cコンパイラです。 CXX変数を "g ++ - 4.8"または "g ++"またはその他のC++コンパイラ実行可能ファイルに設定する必要があります。

+0

病的な好奇心の中で '-x C++ 'も使えますか?おそらく 'CXX =" gcc-4.8 -x C++ "のようなものでしょう。 – jww

+2

@jww g ++ - 4.8がインストールされていない場合、チャンスはありません。 g ++-4.8がgcc-4.8と同じ場所にインストールされていると、コンパイルは成功しますが、リンクステップで使用されると自動的に標準C++ライブラリが追加されることはありません。 – aschepler

関連する問題