【发布时间】:2018-10-26 14:35:05
【问题描述】:
我正在使用 VS2013 和 Anaconda Python 3.6 64 位的全新安装的 Win10 上将 Python 库从 python 2.7 移植到 3.6。
libariy 包含一个 dll,它使用 boost python 作为 python 的包装器,所以我必须重新编译它。
由于之前的 boost 库是针对 python 2.7 编译的,我再次从一个新的 boost_1_63_0 开始,并在 project-config.jam
import option ;
using msvc = 12.0;
using python : 3.6 : C:\\ProgramData\\Anaconda3 ;
option.set keep-going : false ;
使用这些参数
bjam.exe --with-python address-model=64 variant=release link=shared
--build-type=complete
我得到了一套完整的编译库:
└───lib
boost_numpy36-vc120-mt-x64-1_67.dll
boost_numpy36-vc120-mt-x64-1_67.lib
boost_python36-vc120-mt-x64-1_67.dll
boost_python36-vc120-mt-x64-1_67.lib
...
libboost_python36-vc120-mt-gd-x32-1_67.lib
libboost_python36-vc120-mt-gd-x64-1_67.lib
libboost_python36-vc120-mt-x32-1_67.lib
libboost_python36-vc120-mt-x64-1_67.lib
...
libboost_numpy36-vc120-mt-gd-x32-1_67.lib
libboost_numpy36-vc120-mt-gd-x64-1_67.lib
libboost_numpy36-vc120-mt-x32-1_67.lib
libboost_numpy36-vc120-mt-x64-1_67.lib
由于链接器存在一些问题,我在 Visual Studio 中启动了一个新的解决方案。所需的 boost 和 Pyton 文件夹已添加到项目 C/C++-->general-->additional Include 目录中,并且 boost 的 stage\libs 文件夹和 python 的 libs 文件夹已添加到链接器的其他库目录中。
我尝试编译下面的最小示例,该示例在我的其他系统上完美运行,该系统仍在基于旧的基于 python 2.7 的 boost 构建上运行:
#include "stdafx.h"
#define BOOST_PYTHON_STATIC_LIB
#define BOOST_LIB_NAME "boost_numpy"
#include <boost/config/auto_link.hpp>
#include <boost/python/numpy.hpp>
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
编译时出现以下链接器错误
LNK1104: cannot open file 'libboost_numpy-vc120-mt-x64-1_67.lib'
因此,出于某种原因,构建创建了一个名为 boost_numpy36-vc120-mt-x64-1_67.lib 的库,但链接器仍在搜索没有 python 版本 36 的版本。
当我简单地从库中删除 python 版本时,我收到以下链接器错误:
LNK1104: cannot open file 'libboost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc120-mt-gd-x32-1_67.lib'
你知道这里发生了什么吗?
[更新]
好的,所以在找到this 问题后,我意识到该名称与BOOST_LIB_NAME 的定义相关,因此我将其更改为
#define BOOST_LIB_NAME "boost_numpy36"
但不幸的是,我仍然收到第二个链接错误:
LNK1104: cannot open file 'libboost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc120-mt-gd-x32-1_67.lib'
【问题讨论】:
标签: python c++ python-3.x boost