将FindBoost CMAKE指向boost_python Windows 10,VS 2017 [英] Point FindBoost CMAKE to boost_python Windows 10, VS 2017

查看:126
本文介绍了将FindBoost CMAKE指向boost_python Windows 10,VS 2017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的高级目标是安装 BGSlibrary ,这需要在Windows 10上使用Visual增强python Studio2017.我使用cmake 3.9.0从源代码编译了opencv和boost(1.64.0).在BGSLIBRARY的cmake中,我得到了

My high level goal is to install the BGSlibrary which requires boost for python on Windows 10 using Visual Studio 2017. I compiled opencv and boost (1.64.0) from source using cmake 3.9.0. During cmake for BGSLIBRARY I get

$ cmake -DBGS_PYTHON_SUPPORT=ON -DBOOST_ROOT="C:/Program Files/boost_1_64_0/" ..
-- BGSLIBRARY WITH PYTHON SUPPORT: ON
-- OpenCV library status:
--     version: 3.3.0
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.9/           Modules/FindBoost.cmake:1877 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.64.0

  Boost include path: C:/Program Files/boost_1_64_0

  Could not find the following Boost libraries:

          boost_python

  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:75 (find_package)

我在cmake findboost模块上看到了很多问题.好的,让我们从这里开始.

I've seen lots of questions on the cmake findboost module. Okay lets start from here.

  1. 我下载并提取了boost 1.64.0并将其放在此处

  1. 我运行bootstrap.bat和.b2来生成构建增强

  1. I ran bootstrap.bat and .b2 to generate the build boost

C:\ Program Files \ boost_1_64_0> b2工具集= msvc-14.1 --with-python --user-config = user-config.jam

C:\Program Files\boost_1_64_0>b2 toolset=msvc-14.1 --with-python --user-config=user-config.jam

使用用户配置

import toolset : using ;
using msvc : 14.1 ;
using python 
  : 2.7  # Version
  : C:\\Python27\\python.exe  # Interpreter
  : C:\\Python27\\include  # inc dir
  : C:\\Python27\\libs  # link libs
  : # conditions
  ;

我可以在这里看到python源代码

I can see python source here

并可以从Visual Studio 2017命令提示符中确认我在python支持下构建了boost,它成功找到了所有目标.

and can confirm that from within the Visual Studio 2017 command prompt I build boost with python support and it finds all targets successfully.

我可以在这里看到一堆"python" .lib文件.阅读其他问题表明这是它的去向.

I can see a bunch of "python" .lib files here. Reading other questions suggests that is where it goes.

但是我似乎无法接受cmake来查看它. 我尝试将名称libboost_python更改为boost_python.我试过指向cmake -DBOOST_ROOT或-DBOOST_LIBRARYDIR(或非debg,-BOOST_LIBRARYDIR).我尝试将lib目录添加到PATH.但是似乎没有任何作用.这是cmake问题,不完整的Boost安装还是BGSLibrary问题?

But I can't seem to get cmake to see it. I've tried changing the name libboost_python to boost_python. I've tried pointing in cmake -DBOOST_ROOT, or -DBOOST_LIBRARYDIR (or non-debg, -BOOST_LIBRARYDIR). I've tried adding to the lib dir to PATH. But nothing seems to work. Is this a cmake problem, a incomplete boost installation or a problem with BGSLibrary?

编辑

要回答@utopia,有问题的CMakeList部分为

To answer @utopia, the CMakeList section in question reads

if(BGS_PYTHON_SUPPORT)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)

find_package(Boost REQUIRED COMPONENTS python)
find_package(PythonLibs REQUIRED)

message(STATUS "Boost library status:")
message(STATUS "    version: ${Boost_VERSION}")
message(STATUS "    libraries: ${Boost_LIBRARIES}")
message(STATUS "    include path: ${Boost_INCLUDE_DIRS}")

message(STATUS "Python library status:")
message(STATUS "    version: ${PYTHON_VERSION}")
message(STATUS "    libraries: ${PYTHON_LIBRARIES}")
message(STATUS "    include path: ${PYTHON_INCLUDE_DIRS}")

endif()

这是否意味着.lib应该从字面上命名为python.lib?没有其他字符,也可能没有boost_python.lib.具体吗?

Does this mean that the .lib should be literally named python.lib? With no other characters or perhaps boost_python.lib. Is it that specific?

  1. 构建Boost.Python

推荐答案

@utopia使我找到了正确的解决方案. .lib必须从字面上命名为boost_python.lib,而不是随Visual Studio编译器版本,boost版本等附加.在此之后,我能够成功构建,不需要cmake标志.

@utopia led me to the right solution. The .lib needs to be literally named boost_python.lib, not appended with the visual studio compiler version, boost version etc. I was able to successfully build after that, no cmake flags needed.

这篇关于将FindBoost CMAKE指向boost_python Windows 10,VS 2017的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆