【发布时间】:2018-09-28 15:16:28
【问题描述】:
我正在尝试使用 cmake 构建一些代码。该代码使用了一些 Boost 库。因此,我尝试在 cmakefile 中找到 Boost:
find_package(Boost 1.65.1 REQUIRED COMPONENTS unit_test_framework program_options )
我已经通过 apt 安装了 boost 1.58 版本(我使用的是 Linux Mint 18.3),所以我在尝试 cmake 代码时显然会收到错误消息:
CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: /usr/include
Detected version of Boost is too old. Requested version was 1.65.1 (or newer).
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
-- Configuring incomplete, errors occurred!
所以我继续通过源代码下载 Boost 1.65.1 并按照预期的方式构建它并使用前缀安装它
sudo ./b2 install --prefix=/usr/include
当我再次尝试构建代码时,它仍然给出与以前完全相同的错误消息,指出它没有找到更新的版本。我曾尝试卸载 1.58 版并构建,但随后 cmake 根本找不到 Boost。
如何以某种方式安装 Boost,cmake 能够找到它?
提前致谢, 干杯!
【问题讨论】:
-
更改后是否清除了 CMakeCache.txt?你需要这样做。
-
哇,这实际上是问题所在,非常感谢。我应该将此添加到原始问题中还是将其作为答案或类似内容发布?
-
我会想出一个答案