仅当暴露类时才增强python链接错误

时间:2019-01-21 00:27:01

标签: c++ visual-c++ boost cmake boost-python

特别是在MCVC(VS 2017)上使用Hunter package manager通过CMake检索和预编译Boost(1.69)时(在最小代码示例中,请参见底部的链接),我得到以下链接器错误:

1>module.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void * __cdecl boost::python::objects::find_static_type(void *,struct boost::python::type_info,struct boost::python::type_info)" (__imp_?find_static_type@objects@python@boost@@YAPEAXPEAXUtype_info@23@1@Z) referenced in function "private: virtual void * __cdecl boost::python::objects::value_holder<class World>::holds(struct boost::python::type_info,bool)" (?holds@?$value_holder@VWorld@@@objects@python@boost@@EEAAPEAXUtype_info@34@_N@Z)
1>module.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::python::converter::shared_ptr_deleter::shared_ptr_deleter(struct boost::python::converter::shared_ptr_deleter const &)" (__imp_??0shared_ptr_deleter@converter@python@boost@@QEAA@AEBU0123@@Z) referenced in function "public: __cdecl boost::detail::shared_count::shared_count<void *,struct boost::python::converter::shared_ptr_deleter>(void *,struct boost::python::converter::shared_ptr_deleter)" (??$?0PEAXUshared_ptr_deleter@converter@python@boost@@@shared_count@detail@boost@@QEAA@PEAXUshared_ptr_deleter@converter@python@2@@Z)
1>module.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::python::objects::class_base::~class_base(void)" (__imp_??1class_base@objects@python@boost@@QEAA@XZ) referenced in function "int `public: __cdecl boost::python::class_<class World,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified>::class_<class World,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified>(char const *,char const *)'::`1'::dtor$0" (?dtor$0@?0???0?$class_@VWorld@@Unot_specified@detail@python@boost@@U2345@U2345@@python@boost@@QEAA@PEBD0@Z@4HA)
1>module.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::python::objects::register_dynamic_id_aux(struct boost::python::type_info,struct std::pair<void *,struct boost::python::type_info> (__cdecl*)(void *))" (__imp_?register_dynamic_id_aux@objects@python@boost@@YAXUtype_info@23@P6A?AU?$pair@PEAXUtype_info@python@boost@@@std@@PEAX@Z@Z) referenced in function "void __cdecl boost::python::objects::register_dynamic_id<class World>(class World *)" (??$register_dynamic_id@VWorld@@@objects@python@boost@@YAXPEAVWorld@@@Z)

已经将此问题报告给了Hunter here,但是,有谁知道为什么会发生这种情况?

注意:如果我注释掉暴露该类的代码,而只是离开该函数,则不会发生错误。此外,示例代码还包含一个替代的CMakeLists_NoHunter.txt(它不使用Hunter,而只是预构建了1.69二进制文件),并且效果很好(当用CMakeLists.txt替换时)。

我已经在网上搜寻了MSVC类似的增强问题,但似乎找不到任何东西。另外,请注意:BOOST_ALL_NO_LIB定义在Hunter情况下似乎没有任何区别,即我仍然会遇到链接错误。

最小代码示例:https://github.com/Algomorph/minimal_hunter_boost_python_example

0 个答案:

没有答案