在 Windows 上使用 Boost python3 和 numpy3 库时,VS2015 中LNK2019未解析的外
LNK2019 Unresolved External Symbol in VS2015 when using Boost python3 and numpy3 libraries on Windows
>我已经使用以下命令在Windows上下载并构建了Boost 1.64:
b2 --build-type=complete address-model=64 toolset=msvc stage
我在我的主目录中添加了一个user-config.jam文件,告诉Boost在哪里可以找到Python 3:
using python : 3.6 : c:\anaconda3\python ;
然后,我尝试使用 boost::p ython 和 boost::numpy 编译一个小型测试项目:
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
namespace bp = boost::python;
namespace np = boost::python::numpy;
np::ndarray test_make_zeros(int rows, int cols)
{
return np::zeros(bp::make_tuple(rows, cols), np::dtype::get_builtin<float>());
}
BOOST_PYTHON_MODULE(test_boost_numpy)
{
np::initialize();
bp::def("test_make_zeros", test_make_zeros);
}
我正在使用以下CMakeLists.txt文件:
cmake_minimum_required(VERSION 3.8)
project(test_boost_python)
set(BOOST_ROOT "C:/Boost-1.64")
SET(Boost_ADDITIONAL_VERSIONS 1.64)
find_package(PythonLibs 3.6 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
find_package(Boost REQUIRED COMPONENTS python3 numpy3)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_library(test_boost_python SHARED test_boost_python.cpp)
set_target_properties(test_boost_python PROPERTIES PREFIX "" SUFFIX ".pyd")
set_target_properties(test_boost_python PROPERTIES DEFINE_SYMBOL "BOOST_ALL_NO_LIB")
target_link_libraries(test_boost_python ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
我的 boost::p ython 库被命名为 boost_python3-vc140-mt-1_64.lib,而 boost::numpy 在链接到 Python 3.6 时最终为 boost_numpy3-vc140-mt-1_64.lib。
我不得不打开BOOST_ALL_NO_LIB。如果没有,编译器将查找 boost_python-vc140-mt-1_64.lib boost_numpy-vc140-mt-1_64.lib(名称错误,库名称后缺少数字 3(。(这是Windows上的错误吗?
对于我的测试项目,我现在收到以下链接错误:
test_boost_python.obj : error LNK2019: unresolved external symbol "class boost::python::numpy::dtype __cdecl boost::python::numpy::detail::get_float_dtype<32>(void)" (??$get_float_dtype@$0CA@@detail@numpy@python@boost@@YA?AVdtype@123@XZ) referenced in function "public: static class boost::python::numpy::dtype __cdecl boost::python::numpy::detail::builtin_dtype<float,0>::get(void)" (?get@?$builtin_dtype@M$0A@@detail@numpy@python@boost@@SA?AVdtype@345@XZ)
这个缺失符号的原因可能是什么,我应该如何修复它?
这原来是 Boost::P ython 中的一个错误,请参阅问题 #125 并提交 3844c4。它已在 Boost 的最新开发分支中修复。我相信它会在 1.65 版中修复。
相关文章:
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 类C++中的函数问题(LNK2019和LNK1120错误)
- CppSQLite 抛出"LNK2019: unresolved external symbol"错误
- 从VS 2015更新3更新到VS2015更新3 d后浮点计算行为不同的原因
- 使用 VS2015 在 Windows 10 上构建 Fortran .lib x64 位并将其链接到 C++
- VS2015 预处理器定义与点
- VS2015 中的 VC++ 目录
- VS2015 未链接用户32.lib
- Visual Studio中的wxwidgets应用程序给出错误"LNK2019 unresolved external symbol"
- 什么会导致LNK2019 VisualStudio中的错误?
- VS2015/VC++ 在新类模板中禁用默认 #include "stdafx.h"
- 构建 Tensorflow 调试时出现错误LNK2019
- LNK2019 在文件中调用静态成员的方法时出错.cpp
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 获取 c++ mfc vs2015 中弹出资源菜单项的 id
- Qt C++LNK2019:使用QNetworkAccessManager未解析的外部符号
- 链接CPP文件进行测试时发生LNK2019错误
- c++11:在VS2015中分配全局STL "map<string, string>" initializer_list崩溃
- 在 Windows 上使用 Boost python3 和 numpy3 库时,VS2015 中LNK2019未解析的外
- VS2015: LNK2019错误时链接到load.lib