Canot 编译C++它使用了来自 boost 的 odeint
Canot compile C++ which uses odeint from boost
我在 Ubuntu 12.04 上,并且在/usr/include 中已经有一些提升功能。我做了一个
sudo apt-get install libboost-all-dev
这也安装了很多文件。我不想删除此提升并从源代码安装,因为其他几个软件包依赖于 ubuntu 存储库中的版本。这是我想要运行的示例代码:-
#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
所以我使用
sudo chmod -R +x odeint/
这一次,它没有说权限被拒绝,而是抛出了 400 行错误,如下所示 - 来自终端的错误日志>
如何编译?文档中或其他任何地方都没有 odeint 的安装指南
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>
放在代码的开头。
相关文章:
- boost odeint什么时候真正调用观测者
- 将 boost::odeint 与向量类一起使用,而无需调整向量的大小
- Eigen::VectorXd 和 Boost::Odeint,不起作用
- 与 boost odeint 集成期间的析构函数调用
- boost odeint 中的受控误差步进器是否支持复杂的数据类型?
- 编译错误 C2440,并在 boost odeint 中使用make_dense_output
- Boost ODEINT:具有自定义类和向量空间代数的受控步进器
- 是通过BOOST.UNITS支持尺寸分析的Boost Odeint
- 微分方程的解在 boost::odeint 和 scipy.integrate 中完全不同
- 犰狳与 Boost Odeint 冲突:Odeint 在集成期间将状态向量调整为零
- 将 boost odeint 与 std::map 和自定义向量空间代数一起使用时,没有可行的重载'='
- DDE using boost odeint
- 使用C Boost Odeint库的二阶微分方程
- Boost Odeint是否具有跨越式算法
- boost::odeint 在成员类中调用
- Comparison Boost.Odeint vs Scipy.integrate.odeint?
- 如何使用C++ Boost odeint 库求解这个常微分方程
- 如何在boost::odeint中控制bulirsch_stoer方法的顺序
- 使用boost:odeint的简单c++程序中的断言错误
- Boost::odeint演绎/替换失败