【问题标题】:How to handle "Cmake Error: Unable to find the requested Boost libraries"?如何处理“Cmake 错误:无法找到请求的 Boost 库”?
【发布时间】:2019-07-11 03:42:28
【问题描述】:

我正在尝试在 Windows10 环境中构建这个项目https://github.com/DLuensch/StereoVision-ADCensus。正如它所说,我需要建立 openCV、boost、libConfig、PCL、OpenMP、Qt 4.8X。我真的不知道所有这些库是什么,但是,我只是按照提供的说明进行操作。 当我尝试使用 cmake .. 命令构建项目时,CMake 报错“无法找到请求的 Boost 库”,如下图所示

E:\>cd E:\Projects\VisualStudioProjects\StereoVision-ADCensus-master\StereoVision-ADCensus-master\ADCensusBM\build

E:\Projects\VisualStudioProjects\StereoVision-ADCensus-master\StereoVision-ADCensus-master\ADCensusBM\build>cmake ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.15.26730.0
-- The CXX compiler identification is MSVC 19.15.26730.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
OPENMP FOUND
CMake Warning (dev) at CMakeLists.txt:27 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Environment variable Boost_ROOT is set to:

    E:\BOOST\boost_1_70_0\boost_1_70_0

  For compatibility, CMake is ignoring the variable.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at D:/Applications/CMake/share/cmake-3.14/Modules/FindBoost.cmake:2165 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.70.0

  Boost include path: E:/BOOST/boost_1_70_0/boost_1_70_0

  Could not find the following static Boost libraries:

          boost_filesystem
          boost_system

  No Boost libraries were found.  You may need to 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:27 (find_package)


CMake Error at CMakeLists.txt:36 (find_package):
  By not providing "FindPCL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "PCL", but
  CMake did not find one.

  Could not find a package configuration file provided by "PCL" (requested
  version 1.2) with any of the following names:

    PCLConfig.cmake
    pcl-config.cmake

  Add the installation prefix of "PCL" to CMAKE_PREFIX_PATH or set "PCL_DIR"
  to a directory containing one of the above files.  If "PCL" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "E:/Projects/VisualStudioProjects/StereoVision-ADCensus-master/StereoVision-ADCensus-master/ADCensusBM/build/CMakeFiles/CMakeOutput.log".

我对 CMake 或 BOOST 不太熟悉。事实上,我直到昨天才认识他们。所以我不能清楚地弄清楚问题是什么。

首先我搜索了 BOOST 路径中的文件,是的,没有名为“boost_filesystem”或“boost_system”的文件。我怀疑我的 boost 版本是否不匹配。 然后我查看了“CMakeLists.txt”文件。我发现像

这样的声明
# Under Windows the system variable "BOOST_ROOT" must be set to the location of the root directory of Boost.
if(WIN32)
  set(Boost_USE_STATIC_LIBS ON)
  set(Boost_USE_STATIC ON)
endif(WIN32)
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.40.0 COMPONENTS filesystem system REQUIRED)
set(BOOST_FOUND ${Boost_FOUND})
set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIRS})
SET(LIBS ${LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY})

这是否意味着我应该使用 BOOST 1.47.0(我现在已经下载了 1.70.0)? 而且,“set(Boost_NO_BOOST_CMAKE ON)”是否意味着我什至可以在没有 CMake 的情况下构建这个项目?因为我认为 CMake 进度关闭失败是因为不是缺少 BOOST,而是 PCL(我还没有尝试处理)。 如果我可以跳过处理 BOOST 问题,我愿意,因为我有点着急。还是我必须处理它?希望得到帮助。在此先感谢:)

【问题讨论】:

  • 错误信息Could not find the following static Boost libraries 很清楚:CMake 找不到给定的静态库。您可以使用附加选项-DBoost_DEBUG=ON 运行 cmake,它会显示搜索的确切文件名。检查您是否在 Boost 安装中提供了文件名。如果你还没有,那么你需要找到包含给定文件的 Boost 安装。
  • 我想您下载的是 Boost 源代码而不是二进制发行版。请参阅 sourceforge.net/projects/boost/files/boost-binaries/1.70.0/… 以获取适合您的编译器 (MSVC2017) 和体系结构(32 位)的版本。该站点由一些 Boost 维护者运营,因此我信任它。 sourceforge.net/projects/boost/files/boost-binaries/1.70.0 具有其他架构和编译器版本的所有风格。

标签: c++ boost cmake


【解决方案1】:

cmake 只是有一个问题,它找不到与您已安装的 boost 版本链接的 boost 库文件 boost_filesystemboost_system

cmake 需要将BOOST_LIBRARYDIR 设置为存储库文件的目录,就像您将BOOST_ROOT 设置为安装boost 的目录一样。

安装boost 时默认不构建boost 库文件,请参阅:boost: prepare to use a library binary。您可以自己构建库,如here 所述。但是,从here 下载并安装相关的二进制文件会更容易。

注意:CMakeLists.txt 文件行:

find_package(Boost 1.40.0 COMPONENTS filesystem system REQUIRED)

需要最低 boost 1.40.0 版本。除非发生了破坏向后兼容性的更改,否则您应该可以使用 boost 1.70 版。
CMakeLists.txt 文件中引用的 1.40 和 1.47 版本非常旧...

【讨论】:

  • 谢谢。我会尽力。我一开始没有设置 BOOST_LIBRARYDIR ,因为 CMake 使用“或”连接设置这两个变量的指令。然后我忘记了这个变量...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-21
  • 2014-08-02
  • 2019-02-06
  • 1970-01-01
  • 1970-01-01
  • 2018-08-20
相关资源
最近更新 更多