使用 python3 为 msvc 构建 boost python - 链接器错误
Building boost python for msvc with python3 - Linker Error
我正在将Python Libary从python 2.7移植到3.6,在全新安装的Win10上,VS2013和Anaconda Python 3.6 64位。
库包含一个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中启动了一个新的Soulution。所需的 boost 和 Pyton 文件夹已添加到项目 C/C++-->general-->附加包含目录中,并且 boost 的stagelibs
文件夹和 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'
知道这里发生了什么吗?
[更新]
好的,所以在找到这个问题后,我意识到该名称与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'
我无法解决描述错误,但我在这里找到了一组预编译的库: https://www.lfd.uci.edu/~gohlke/pythonlibs/
你提到的问题:
LNK1104:无法打开文件 'libboost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-VC120-MT-GD-x32-1_67.lib'
在此提交中已解决。
要获得问题的完整上下文,您可以检查此内容
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误