gpt4 book ai didi

c++ - Eigen C++ 库给出 C++ 11 选项的错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:42:41 71 4
gpt4 key购买 nike

我有以下使用 Eigen C++ 库的 C++ 代码。

#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,Eigen 库版本是 3.2.10。

最佳答案

看来你把Eigen include目录直接放在头文件搜索路径上了。这意味着当标准 <array>包含头文件,编译器实际上会包含 Eigen array头文件。

更改您的 -I不包括完整路径的标志,仅包括例如../SP_ToolBox/ExternalLibraries/Eigen (即删除最后一个 /Eigen )。

然后包括<Eigen/Dense>相反。

关于c++ - Eigen C++ 库给出 C++ 11 选项的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40435997/

71 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com