【发布时间】:2026-02-03 19:30:02
【问题描述】:
我刚刚将我的服务器升级到 ubuntu 20.04 LTS。
我现在正在尝试在上面安装各种不同的代码包,并收到与 boost 安装相关的错误。
我没有从源代码构建,而是使用 apt 安装了 boost 1.71.0:
sudo apt-get install libboost-all-dev
但是,当我尝试编译代码时,我遇到了以下错误:
fatal error: boost/algorithm/string/trim.hpp: No such file or directory
15 | #include <boost/algorithm/string/trim.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boost/log/sinks/text_ostream_backend.hpp: No such file or directory
6 | #include <boost/log/sinks/text_ostream_backend.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
过去 3 个小时我一直在尝试查找那些 hpp 文件,但没有成功。里面什么都没有:
/usr/local/include/
/usr/local/lib/
/usr/lib/
/usr/include/boost *doesn't exist*
知道有什么问题吗? 我试图避免从源代码而不是 Ubuntu 软件包安装 boost,但我必须这样做吗?
【问题讨论】:
-
@Ranoiaetep 是的,我已经看到了 *。这指的是默认值
/usr/include/boost,但那里什么都没有。另外:locate boost将 /usr/share/boost-build/ 显示为包含文件的文件夹,但其中仅包含大量 .jam 文件。我没有找到任何 .hpp 文件。 -
sudo apt-get install libboost-all-dev成功了吗?再试一次,看看输出消息。 -
@prehistoricpenguin 我已经做了很多安装。
sudo apt-get install libboost-all-dev Reading package lists... Done Building dependency tree Reading state information... Done libboost-all-dev is already the newest version (1.71.0.0ubuntu2). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.但我也使用过remove和install甚至reinstall。
标签: c++ ubuntu boost ubuntu-20.04