【发布时间】:2017-07-14 21:31:34
【问题描述】:
今天早上我安装了 Python 3.6,得到了我的 b2 配置来编译 boost lib,并且在 lib 路径中确实有两种风格的 libboost_python3...。然后用一个简单的:
#include "stdafx.h"
#include <boost/python.hpp>
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
我收到一个链接器错误:
LINK : fatal error LNK1104: cannot open file 'boost_python-vc140-mt-gd-1_63.lib'
我已经搜索过像USING_BOOST_PYTHON3 这样的标志,但我读到的每一篇文章都说它应该是自动的。根据我构建的内容,该 Boost 应该包含正确的库。
This guy 有同样的问题,但从未得到答案。这与我可以访问右侧“类似问题”中的链接一样接近。但我看不出 VS 是如何参与其中的,因为 boost 会选择库。
更新:我刚刚发现:
#if PY_MAJOR_VERSION == 2
# define BOOST_LIB_NAME boost_python
#elif PY_MAJOR_VERSION == 3
# define BOOST_LIB_NAME boost_python3
#endif
所以现在看起来为什么我的主要版本是 2 而不是 3?即使我:
#define PY_MAJOR_VERSION 3
就在我的stdafx.h 的顶部,它仍然与 python 2 库链接。 !?
又一次更新:
这么早,我没有“安装”python 2.7,我将附加库设置为C:\cpp\Python27\libs,我只是将它设置为C:\cpp\Python36_3\libs,现在我得到了:
LINK : fatal error LNK1104: cannot open file 'python27.lib'
这是有道理的,因为 boost 试图链接到 2.x 而不是 3.x
【问题讨论】:
标签: python-3.x boost