我在Ubuntu 12.04&在/ usr / include中已经有了一些提升。我做了一个
sudo apt-get install libboost-all-dev
并且安装了很多文件。我不想删除此提升并从源代码安装,因为其他几个软件包依赖于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行错误 - &gt; error log from terminal
我该如何编译?文档或其他任何地方都没有odeint的安装指南
答案 0 :(得分:1)
这部分boost
似乎使用了C ++ 11的功能。因此,您需要在编译器调用中添加-std=c++0x
或-std=c++11
。
后续错误test.cpp: In function ‘int main()’: test.cpp:30:5: error: ‘stepper_euler’ was not declared in this scope
指向另一个错误来源:您忘记包含声明stepper_euler
的文件。将适当的#include <file>
放在代码的开头。