【发布时间】:2018-12-19 12:38:41
【问题描述】:
这是我第一次尝试为生产级项目编写 cmake 文件,我只是尝试使用 cmake 定位 boost python(v 1.67.0) 包。
我有一个很小的CMakeLists.txt。
cmake_minimum_required(VERSION 3.13)
find_package(Boost 1.67.0 REQUIRED COMPONENTS system python37)
if(Boost_FOUND)
message("Boost_FOUND")
endif()
如果我只是尝试查找system,它会正常工作,但当我添加python37 时会失败。根据 FindBoost documentation,我需要按照我提到的方式提及它。这是我得到的输出:
CMake Error at /usr/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
Unable to find the requested Boost libraries.
Boost version: 1.67.0
Boost include path: /usr/include
Could not find the following Boost libraries:
boost_python37
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:2 (find_package)
-- Configuring incomplete, errors occurred!
当我运行$ locate libboost_python 时,我得到以下输出:
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1
/usr/lib/x86_64-linux-gnu/libboost_python27.so.1.67.0
/usr/lib/x86_64-linux-gnu/libboost_python3-py37.so.1.65.1
/usr/lib/x86_64-linux-gnu/libboost_python37.so.1.67.0
鉴于此输出,我假设包/库存在。
因此,我尝试在CMakeLists.txt 中添加以下行:
set(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu")
但错误仍然存在。我在这里错过了什么?
【问题讨论】:
-
你不需要
if(Boost_FOUND),你设置REQUIRED。 -
set(BOOST_LIBRARYDIR "/usr/lib/x86_64-linux-gnu")被添加到文件的哪个位置? -
就在
find_package行之前 -
运行
cmake和-DBoost_DEBUG=ON并查看实际搜索了哪些文件。 -
@Tsyvarev:我有一个巨大的标志列表及其对应的值,有什么需要检查的具体内容吗?有些包含我在
BOOST_LIBRARYDIR中添加的路径
标签: c++ boost cmake boost-python