针对Boost python 3.6的链接.找不到boost_python而不是boost_python3 [英] Linking against Boost python 3.6. can't find boost_python instead of boost_python3

查看:762
本文介绍了针对Boost python 3.6的链接.找不到boost_python而不是boost_python3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在链接Boost python时遇到问题.

I have problems linking against boost python.

我正在使用Visual Studio 2017并使用以下命令行编译boost 1_64程序包:

I am using Visual Studio 2017 and compiled the boost 1_64 package with the following command line:

b2 -a toolset=msvc-14.1 --build_type=complete stage variant=debugthreading=multi link=shared runtime-link=shared define=_ITERATOR_DEBUG_LEVEL=0 address-model=64

使用此user-config.jam:

with this user-config.jam:

using python 
: 3.6                   # Version
: C:\\Python36\\python.exe      # Python Path
: C:\\Python36\\include         # include path
: C:\\Python36\\libs            # lib path(s)
: <define>BOOST_ALL_NO_LIB=1
;

但是在使用运行时库构建我的c ++项目时:多线程DLL(/MD),我不断收到此错误消息:

But while building my c++ project with runtime libary: Multi-threaded DLL (/MD) I keep getting this error message:

Error   LNK1104 cannot open file 'boost_python-vc141-mt-gd-1_64.lib'    

但是我编译的boost库包含以下boost_python文件:

but the boost libs I compiled contain the following boost_python files:

boost_python3-vc141-mt-gd-1_64.dll
boost_python3-vc141-mt-gd-1_64.lib

有人对Python 3的Boost有经验吗?经过数小时的尝试,我找不到一个好的解决方案. 顺便说一句:将文件重命名为boost_python-(删除3)可以正常工作. 但是我不认为这是正确的方法

Does someone have experience with boost for python 3? After hours of trying, I can't find a good solution. Btw.: renaming the files to boost_python- (removing the 3) works fine. But I don't think that this is the correct way

VC项目设置:

添加.包含目录:

C:\Python36\include;D:\ws\boost_1_64_0\boost_1_64_0;

添加.库目录:

D:\ws\boost_1_64_0\boost_1_64_0\stage\lib;C:\Python36\libs;


已关闭:boost的自动链接功能无法在python 3上正常使用.boost_module_name宏设置为boost_python(缺少3),并且生成的库包含3.


Closed: The autolink feature of boost did not work correctly with python 3. The boost_module_name macro was set to boost_python (missing the 3) and the generated libs contained the 3.

-> 关闭自动链接并手动添加所需的库.

--> Turned auto link off and added the required libs manually.

解决方案 a)转到boost/python/detail/config.hpp并将BOOST_LIB_NAMe更改为boost_python3而不是boost_python.

Solution a) Go to boost/python/detail/config.hpp and change BOOST_LIB_NAMe to boost_python3 instead of boost_python.

解决方案 b)通过定义BOOST_ALL_NO_LIB,然后将boost_python3 ... lib显式设置为链接器依赖项,来启用自动链接.

Solution b) Turn auto Linkage of by defining BOOST_ALL_NO_LIB and then explicitly set boost_python3...lib as linker dependency.

推荐答案

很抱歉来到这里晚了,我自己也经历了同样的废话.事实证明,boost无法很好地处理两次安装(甚至是py3.x本身)

Sorry for coming in late here, just went through the same nonsense myself. Turns out that boost doesn't handle two installs very well (or even a py3.x by itself)

您绝对可以通过进入<boost/python/detail/config.hpp>并进行快速更改来解决此问题.为了使boost可以同时与python 2.x(2.7,大概)和3.x一起使用,我建议更改:

You can definitely solve this by going into <boost/python/detail/config.hpp> and making a quick change. To allow for boost to work with both python 2.x (2.7, presumably) and 3.x, I'd suggest changing:

#define BOOST_LIB_NAME boost_python

#if PY_MAJOR_VERSION >=3
  #define BOOST_LIB_NAME boost_python3
#else
  #define BOOST_LIB_NAME boost_python
#endif

这篇关于针对Boost python 3.6的链接.找不到boost_python而不是boost_python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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