【问题标题】:How to install a header-only (odeint) library in linux?如何在 linux 中安装仅标头(odeint)库?
【发布时间】:2013-08-18 14:21:52
【问题描述】:

我在 Debian Sqeeze 下使用 g++ 4.4,并且安装了 boost。我可以运行带有标题的简单提升矩阵example

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

但我还想添加 odeint 标头:

#include <boost/numeric/odeint.hpp>

但是,这是不可能的,因为我的 /usr/include/boost/numeric 文件夹只列出了

conversion  interval  interval.hpp  ublas

如何安装odeint?

odeint 是一个只有头文件的库,不需要链接到预编译的代码。我已经下载了.tar 并将odeint 文件夹和odeint.hpp 文件复制到我的/usr/include/boost/numeric 文件夹中。但是,它不起作用。编译时出现错误:

error: boost/range/algorithm/copy.hpp: No such file

【问题讨论】:

  • 你安装了 boost::range 吗?它可以很好地找到 odeint 标头,但其中一个包含范围库中不存在的标头。
  • @deong:谢谢,提升/范围/算法丢失。可能是因为我将 boost 安装为 debian 打包而不是 boost_1_54_0.tar.bz2.。现在我安装了 boost_1_54_0.tar.bz2,一切正常,因为 odeint 包含在这个发行版中。

标签: c++ linux boost g++ odeint


【解决方案1】:

我已删除通过

安装的 boost 库
apt-get install libboost1.42-dev

其中不包含odeint。然后我安装了boost_1_54_0.tar.bz2.,它已经包含了odeint。现在我可以运行 odeint 程序,例如this.

【讨论】:

  • 现在您可能有 2 个版本,如果您无意中将它们混合在一起,您很有可能会违反 ODR。
  • @Igor R. 我已经从 /usr/include/ 中删除了旧的 bo​​ost 目录。去掉旧的 1.42 boost 版本还不够吗?
  • 对不起,也许我误解了你。如果您完全删除了标头和二进制文件,那就没问题了。实际上,拥有多个 Boost 版本也是非常合理的,但您应该确保不要混合使用它们。
猜你喜欢
  • 2013-06-12
  • 2018-10-10
  • 1970-01-01
  • 1970-01-01
  • 2014-07-24
  • 2021-12-23
  • 2020-09-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多