首页 > 解决方案 > 如何安装和使用 Boost.Program_options 库?

问题描述

我正在尝试构建以下软件包: https ://github.com/kahypar/kahypar

在需求部分,它要求 Boost.Program_options我真的不知道那是什么以及我应该如何处理它。如果您能帮助我,我将不胜感激。我正在使用 macOS,并且我已经通过以下方式安装了 boost:

brew install boost

但它仍然不起作用。

标签: c++boost

解决方案


注意

因为有些人似乎没有意识到,手动说明适用于 macOS 100%(除了如何获取构建必需品,但显然 OP 已经有了它们)

但是,我无法在 macOS 上演示,因为我没有 Mac。对不起

正常的方法是在您的发行版之后或手动安装 boost:

发行版

例如 Ubuntu 20.04

apt -qq update
apt -qqyy install build-essential libboost-all-dev cmake git


git clone --recurse-submodules  https://github.com/kahypar/kahypar
cmake -B build kahypar/
cmake --build build -j5

煮点咖啡。利润。

手动构建

这使用了 Boost 库 - 只构建我需要节省时间的东西:

apt -qqyy install build-essential cmake git python3-dev wget
wget https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.bz2
tar xf boost_1_75_0.tar.bz2
(cd boost_1_75_0; ./bootstrap.sh; ./b2 --with-program_options)

git clone --recurse-submodules  https://github.com/kahypar/kahypar
BOOST_ROOT="$PWD/boost_1_75_0" cmake -B build kahypar/
cmake --build build -j5

现场演示

的截屏

当然,您可能只是指向BOOST_ROOTbrew install 所在的位置,但我无法帮助您,因为我无法测试它。您很可能需要单独设置包含/链接路径。


推荐阅读