它采用odeint从boost Canot编译C ++ [英] Canot compile C++ which uses odeint from boost
问题描述
我在Ubuntu 12.04和放大器;有一些外商投资企业提振已经在/ usr / include目录。我做了一个
I'm on Ubuntu 12.04 & had some boost fies already in /usr/include. I did a
sudo apt-get install libboost-all-dev
和安装大量的文件了。我不想删除此升压和其他几个包依赖于从Ubuntu软件库的版本从源代码安装。这是样板code我想运行: -
and that installed a lot of files too. I don't want to remove this boost and install from source as several other packages depend on the version from the ubuntu repos. This is the sample code I want to run :-
#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.CPP
,它抛出一个错误
/usr/include/boost/numeric/odeint.hpp权限被拒绝
ON first compile g++ -o test test.cpp
, it threw an error
/usr/include/boost/numeric/odeint.hpp permission denied
于是我改变了递归使用所有odeint文件的文件许可权
So I changed the file permission of all odeint files recursively using
sudo chmod -R +x odeint/
这时候,它并没有说拒绝的权限,但扔了400线的错误,因为在这里可以看到 - > 错误从终端日志
This time, it did not say permission denied but threw 400 lines of error as can be seen here -> error log from terminal
我如何编译它?还有在文档中的odeint没有安装指南或其他地方
How do I compile it ? There are no install guides for odeint in the documentation or anywhere else
推荐答案
升压
的这部分似乎使用C ++ 11的特性。因此,您需要为 -std =的C ++ 0x
或 -std = C ++ 11
添加到您的编译器调用。
This part of boost
seems to use C++11 features. Therefore you need to add either -std=c++0x
or -std=c++11
to your compiler invocation.
随后的误差 TEST.CPP:在函数'廉政的main()':TEST.CPP:30:5:错误:stepper_euler没有在这个范围内声明
您指向错误的另一个来源:你忘了,包括在 stepper_euler
声明文件。把合适的的#include&LT;文件&gt;
你的code的开始
The subsequent error test.cpp: In function ‘int main()’: test.cpp:30:5: error: ‘stepper_euler’ was not declared in this scope
points you to another source of error: You forgot to include the file in which stepper_euler
is declared. Put the appropriate #include <file>
at the beginning of your code.
这篇关于它采用odeint从boost Canot编译C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!