【发布时间】:2013-11-09 11:44:21
【问题描述】:
我使用的是 Ubuntu 12.04,并且在 /usr/include 中已经有了一些提升文件。我做了一个
sudo apt-get install libboost-all-dev
这也安装了很多文件。我不想删除这个 boost 并从源代码安装,因为其他几个包依赖于 ubuntu repos 的版本。这是我要运行的示例代码:-
#include <iostream>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
typedef vector< double > state_type;
const double sigma = 10.0;
const double R = 28.0;
const double b = 8.0 / 3.0;
void lorenz( state_type &x , state_type &dxdt , double t )
{
dxdt[0] = sigma * ( x[1] - x[0] );
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
dxdt[2] = x[0]*x[1] - b * x[2];
}
int main()
{
const double dt = 0.01;
state_type x(3);
x[0] = 1.0 ;
x[1] = 0.0 ;
x[2] = 0.0;
stepper_euler< state_type > stepper;
stepper.adjust_size( x );
double t = 0.0;
for( size_t oi=0 ; oi<10000 ; ++oi,t+=dt )
{
stepper.do_step( lorenz , x , t , dt );
cout << x[0] << " " << x[1] << " " << x[2] << endl;
}
}
先编译g++ -o test test.cpp,报错
/usr/include/boost/numeric/odeint.hpp permission denied
所以我使用递归更改了所有odeint文件的文件权限
sudo chmod -R +x odeint/
这一次,它没有说权限被拒绝,而是抛出了 400 行错误,如下所示 -> error log from terminal
如何编译它?文档或其他任何地方都没有 odeint 的安装指南
【问题讨论】:
-
首先:文件存在吗?
-
是的,所有必需的文件都存在
-
难道 odeint 与 ubuntu repos 的 boost 版本不兼容,除了安装默认提供 odeint 的源代码的最新 boost 之外别无选择?
-
然后从日志中列出的第一个错误开始:
/usr/include/boost/numeric/odeint/stepper/controlled_runge_kutta.hpp:307:42: error: ‘bind’ is not a member of ‘boost::numeric::odeint::detail’。确保它实际上是第一个。您可以使用-Wfatal-errors编译以在第一个错误时中止。 -
@stefan 带有 -Wfatal-errors 标志,它给出:- '在来自 /usr/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp:25:0 的文件中,来自/usr/include/boost/numeric/odeint/stepper/euler.hpp:23,来自 /usr/include/boost/numeric/odeint.hpp:27,来自 test.cpp:2:/usr/include/boost/numeric /odeint/util/bind.hpp:44:14: 错误:'std::bind' 尚未声明编译因 -Wfatal-errors'而终止