2016-11-05 8 views
4

私はEigen C++ライブラリを使用した次のC++コードを持っています。Eigen C++ライブラリはC++ 11のオプションでエラーを返します

#include "Dense" 
#include <iostream> 

int main() 
{ 
    Eigen::MatrixXf x(10,10); 
    x.setRandom(); 
    std::cout<<"x is ..\n"<<x<<std::endl; 


    return 0; 
} 

"-std = gnu ++ 11"でg ++を試すと、次のエラーが発生します。

In file included from /usr/include/c++/4.8/tuple:39:0, 
       from /usr/include/c++/4.8/functional:55, 
       from ../SP_ToolBox/ExternalLibraries/Eigen/Eigen/Core:153, 
       from ../SP_ToolBox/ExternalLibraries/Eigen/Eigen/Dense:1, 
       from test.cpp:1: 
../SP_ToolBox/ExternalLibraries/Eigen/Eigen/array:8:4: error: #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 
    #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 
    ^
In file included from /usr/include/c++/4.8/functional:55:0, 
       from ../SP_ToolBox/ExternalLibraries/Eigen/Eigen/Core:153, 
       from ../SP_ToolBox/ExternalLibraries/Eigen/Eigen/Dense:1, 
       from test.cpp:1: 
/usr/include/c++/4.8/tuple:885:33: error: ‘array’ was not declared in this scope 
    struct __is_tuple_like_impl<array<_Tp, _Nm>> : true_type 
           ^
/usr/include/c++/4.8/tuple:885:44: error: wrong number of template arguments (2, should be 1) 
    struct __is_tuple_like_impl<array<_Tp, _Nm>> : true_type 
              ^
/usr/include/c++/4.8/tuple:873:12: error: provided for ‘template<class> struct std::__is_tuple_like_impl’ 
    struct __is_tuple_like_impl : false_type 
      ^
/usr/include/c++/4.8/tuple:885:47: error: expected unqualified-id before ‘>’ token 
    struct __is_tuple_like_impl<array<_Tp, _Nm>> : true_type 

"-std = gnu ++ 11"オプションを削除すると問題なくコンパイルされます。 gccのバージョンは4.8.4、固有ライブラリのバージョンは3.2.10です。

答えて

5

Eigenのインクルードディレクトリをヘッダーファイルの検索パスに直接入れたようです。つまり、標準<array>ヘッダーファイルが含まれている場合、コンパイラは実際には代わりにEigen arrayヘッダーファイルを含めます。

-Iフラグをフルパスを含まないように変更してください。 ../SP_ToolBox/ExternalLibraries/Eigen(つまり、最後の/Eigenを削除します)。

次に、代わりに<Eigen/Dense>を含めてください。

関連する問題