【问题标题】:Cannot find Boost when installing Dlib安装 Dlib 时找不到 Boost
【发布时间】:2017-04-05 00:21:27
【问题描述】:

我是 Windows 用户,目前正在使用 Windows 10。我正在尝试从过去 8 小时开始在 python 3.5 上安装 Dlib,但失败了。每当我尝试“pip install Dlib”或尝试“python setup.py install”(在 dlib 文件夹中)时,我都会收到错误消息“cmake configuration failed”。在整个执行过程中,我可以看到“找不到 BOOST”。有人可以在这里指导我吗?

>>python setup.py install
running install
running bdist_egg
running build
Detected Python architecture: 32bit
Detected platform: win32
Removing build directory C:\Users\Tabish\Desktop\dlib-master\./tools/python/build
Configuring cmake ...
-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.24213.1
-- The CXX compiler identification is MSVC 19.0.24213.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:61 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1499 (message):
  No header defined for python-py34; skipping header check
Call Stack (most recent call first):
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:61 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
-- Could NOT find Boost
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:63 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1499 (message):
  No header defined for python-py35; skipping header check
Call Stack (most recent call first):
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:63 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
-- Could NOT find Boost
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:66 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1499 (message):
  No header defined for python3; skipping header check
Call Stack (most recent call first):
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:66 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
-- Could NOT find Boost
CMake Warning at C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
  C:/Program Files (x86)/Python35-32/Lib/site-packages/cmake/data/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
  C:/Users/Tabish/Desktop/dlib-master/dlib/cmake_utils/add_python_module:69 (FIND_PACKAGE)
  CMakeLists.txt:6 (include)
-- Could NOT find Boost
-- Found PythonLibs: C:/Program Files (x86)/Python35-32/libs/python35.lib (found suitable version "3.5.2", minimum required is "3.4")
--  *****************************************************************************************************
-- We couldn't find the right version of boost python.  If you installed boost and you are still getting this error then you might have installed a version of boost that was compiled with a different version of visual studio than the one you are using.  So you have to make sure that the version of visual studio is the same version that was used to compile the copy of boost you are using.
--  Set the BOOST_ROOT and BOOST_LIBRARYDIR environment variables before running cmake.
--  E.g.  Something like this:
--     set BOOST_ROOT=C:\local\boost_1_57_0
--     set BOOST_LIBRARYDIR=C:\local\boost_1_57_0\stage\lib
--
--  You will also likely need to compile boost yourself rather than using one of the precompiled
--  windows binaries.  Do this by going to the folder tools\build\ within boost and running
--  bootstrap.bat.  Then run the command:
--     b2 install
--  And then add the output bin folder to your PATH.  Usually this is the C:\boost-build-engine\bin
--  folder. Finally, go to the boost root and run a command like this:
--     b2 -a --with-python address-model=64 toolset=msvc runtime-link=static
--  When it completes, set BOOST_LIBRARYDIR equal to wherever b2 put the compiled libraries.
--  Note that you will need to set the address-model based on if you want a 32 or 64bit python library.
--
--  Next, when you invoke cmake to compile dlib you may have to use cmake's -G option to set the
--  64 vs. 32bit mode of visual studio.  Also, if you want a Python3 library you will need to
error: cmake configuration failed!

【问题讨论】:

  • 如果您使用 64 位版本的 python,您可以通过 pip install dlib 使用预编译的二进制文件。
  • 不,我使用的是 32 位版本@Davis

标签: c++ python-3.x boost dlib


【解决方案1】:

尝试以下步骤:(已针对 Windows 调整)

  1. 下载boost源码包。

  2. cd 进入解压后的 boost 文件夹

  3. 运行.\bootstrap.bat

  4. 运行.\b2 runtime-link=shared link=shared。 (这将创建动态提升库,这些库本身链接到动态运行时库。

  5. 设置以下环境变量(当然是在调整到你自己的路径之后):

    BOOST_LIBRARYDIR="C:\Developer\boost_1_62_0\stage\lib"
    

    BOOST_INCLUDEDIR="C:\Developer\boost_1_62_0"
    

    BOOST_ROOT="C:\Developer\boost_1_62_0"
    
  6. python setup.py install重试

当 CMake 的 find_package() 找不到 boost 时,我遇到了类似的问题,原因是仅使用 b2 构建 boost,没有参数 link=shared 导致生成的 .lib 文件具有前缀“lib " 在 Windows 上,CMake 的 find_package() 不希望库具有 "lib" 前缀。

【讨论】:

  • 不过,另一个消息来源告诉我使用bjamb2bjam 有什么区别?
  • 这里是b2和bjam的区别:boost.org/build/doc/html/bbv2/faq/names.html
  • 直到我安装了 VS2015 **update 3** 之前我在python setup.py install 中没有成功(似乎只有这个更新包含 dlib 需要的一些最新 C++ 标准)。
猜你喜欢
  • 2017-10-01
  • 1970-01-01
  • 2018-12-19
  • 2016-07-25
  • 1970-01-01
  • 2017-05-08
  • 2017-10-02
相关资源
最近更新 更多