0

I am trying to compile the following example from ODEINT library. I downloaded and installed the boost library and then add path to CodeBlocks as guided by some of threads online. However, errors still occur. I am very grateful if you can please have a look and tell me what's going on. Here is the code from the example (I just copied them down):

#include <iostream>
#include <boost/numeric/odeint.hpp>

#define tab "\t"

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( int argc , char **argv )
{
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] << tab << x[1] << tab << x[2] << endl;
}
}

And here are the errors received: Build: Debug in depi (compiler: GNU GCC Compile) In function 'int main(int, char**) |error: 'stepper_euler' was not declared in this scope 31|error: expected primary-expression before '>' token error: 'stepper' was not declared in this scope| uild failed: 3 error(s), 0 warning(s) (0 minute(s), 9 second(s))

hn.phuong
  • 835
  • 6
  • 15
  • 24
  • 1
    It seems you are using an old version. see http://stackoverflow.com/questions/19875527/canot-compile-c-which-uses-odeint-from-boost See the comment by **@headmyshoulder** which states "There is no stepper 'stepper_euler' in odeint. I guess the example you are using is from an old version of odeint." – CroCo Dec 21 '15 at 22:18
  • I am on windows, so I am not sure if the procedure should be different from Unbutu in the link you provided. Thanks – hn.phuong Dec 21 '15 at 22:20
  • The library is compatible in Windows and Linux. – CroCo Dec 21 '15 at 22:22
  • I downloaded boost library from boost.org (newest version 1.60.0). ..>Installed-->link to CodeBlocks. Is this all I have to do? – hn.phuong Dec 21 '15 at 22:22
  • hi CroCo: you are right. I tried with new examples from Odeint and it worked. Thanks so much! – hn.phuong Dec 21 '15 at 22:30

0 Answers0