Eigen C ++ Library在C ++ 11选项中出错

时间:2016-11-05 07:52:46

标签: c++ c++11 eigen3

我有以下C ++代码,其中我使用了Eigen C ++ Library。

#include "Dense"
#include <iostream>

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


    return 0;
}

当我尝试使用&#34; -std = gnu ++ 11&#34;它给出了以下错误。

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

如果删除&#34; -std = gnu ++ 11&#34;它会编译好。选项。 我的gcc版本是4.8.4,而Eigen Library版本是3.2.10。

1 个答案:

答案 0 :(得分:5)

您似乎已将Eigen包含目录直接放在头文件搜索路径中。这意味着当包含标准 <array>头文件时,编译器实际上将包含Eigen array头文件。

将您的-I标记更改为不包含完整路径,仅限于../SP_ToolBox/ExternalLibraries/Eigen(即删除最后一个/Eigen)。

然后包括<Eigen/Dense>