windows系统Visual stdio生成解决方案报错:
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) void * __cdecl boost::python::objects::find_dynamic_type(void *,struct boost::python::type_info,struct boost::python::type_info)" (__imp_?find_dynamic_type@objects@python@boost@@YAPEAXPEAXUtype_info@23@1@Z),该符号在函数 "private: virtual void * __cdecl boost::python::objects::pointer_holder<class std::unique_ptr<class ProjectorInterface2D,struct std::default_delete<class ProjectorInterface2D> >,class ProjectorInterface2D>::holds(struct boost::python::type_info,bool)" (?holds@?$pointer_holder@V?$unique_ptr@VProjectorInterface2D@@U?$default_delete@VProjectorInterface2D@@@std@@@std@@VProjectorInterface2D@@@objects@python@boost@@EEAAPEAXUtype_info@34@_N@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__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),该符号在函数 "public: __cdecl std::_Compressed_pair<struct boost::python::converter::shared_ptr_deleter,void *,0>::_Compressed_pair<struct boost::python::converter::shared_ptr_deleter,void *,0><struct boost::python::converter::shared_ptr_deleter,void * &>(struct std::_One_then_variadic_args_t,struct boost::python::converter::shared_ptr_deleter &&,void * &)" (??$?0Ushared_ptr_deleter@converter@python@boost@@AEAPEAX@?$_Compressed_pair@Ushared_ptr_deleter@converter@python@boost@@PEAX$0A@@std@@QEAA@U_One_then_variadic_args_t@1@$$QEAUshared_ptr_deleter@converter@python@boost@@AEAPEAX@Z) 中被引用
4> 已定义且可能匹配的符号上的提示:
4> "__declspec(dllimport) public: __cdecl boost::python::converter::shared_ptr_deleter::shared_ptr_deleter(class boost::python::handle<struct _object>)" (__imp_??0shared_ptr_deleter@converter@python@boost@@QEAA@V?$handle@U_object@@@23@@Z)
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl boost::python::objects::class_base::~class_base(void)" (__imp_??1class_base@objects@python@boost@@QEAA@XZ),该符号在函数 "int `public: __cdecl boost::python::class_<class ProjectorInterface2D,class boost::noncopyable_::noncopyable,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified>::class_<class ProjectorInterface2D,class boost::noncopyable_::noncopyable,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified>(char const *,enum python::class_<class ProjectorInterface2D,class boost::noncopyable_::noncopyable,struct boost::python::detail::not_specified,struct boost::python::detail::not_specified>::no_init_t)'::`1'::dtor$0" (?dtor$0@?0???0?$class_@VProjectorInterface2D@@Vnoncopyable@noncopyable_@boost@@Unot_specified@detail@python@4@U5674@@python@boost@@QEAA@PEBDW4no_init_t@12@@Z@4HA) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__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),该符号在函数 "void __cdecl boost::python::objects::register_dynamic_id<class ProjectorInterface2D>(class ProjectorInterface2D *)" (??$register_dynamic_id@VProjectorInterface2D@@@objects@python@boost@@YAXPEAVProjectorInterface2D@@@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) void __cdecl boost::python::objects::add_cast(struct boost::python::type_info,struct boost::python::type_info,void * (__cdecl*)(void *),bool)" (__imp_?add_cast@objects@python@boost@@YAXUtype_info@23@0P6APEAXPEAX@Z_N@Z),该符号在函数 "void __cdecl boost::python::objects::register_conversion<class ProjectorInterface2D,class ProjectorInterface3D>(bool,class ProjectorInterface2D *,class ProjectorInterface3D *)" (??$register_conversion@VProjectorInterface2D@@VProjectorInterface3D@@@objects@python@boost@@YAX_NPEAVProjectorInterface2D@@PEAVProjectorInterface3D@@@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl boost::python::numpy::ndarray::ndarray(struct boost::python::detail::borrowed_reference_t *)" (__imp_??0ndarray@numpy@python@boost@@QEAA@PEAUborrowed_reference_t@detail@23@@Z),该符号在函数 "public: class boost::python::numpy::ndarray __cdecl boost::python::converter::object_manager_value_arg_from_python<class boost::python::numpy::ndarray>::operator()(void)const " (??R?$object_manager_value_arg_from_python@Vndarray@numpy@python@boost@@@converter@python@boost@@QEBA?AVndarray@numpy@23@XZ) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class boost::python::numpy::ndarray __cdecl boost::python::numpy::ndarray::copy(void)const " (__imp_?copy@ndarray@numpy@python@boost@@QEBA?AV1234@XZ),该符号在函数 "class boost::python::numpy::ndarray __cdecl backward(class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,double,double,unsigned int,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?backward@@YA?AVndarray@numpy@python@boost@@V1234@00NNIIAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __int64 __cdecl boost::python::numpy::ndarray::shape(int)const " (__imp_?shape@ndarray@numpy@python@boost@@QEBA_JH@Z),该符号在函数 "class boost::python::numpy::ndarray __cdecl forward(class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,double,double)" (?forward@@YA?AVndarray@numpy@python@boost@@V1234@00NN@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: char * __cdecl boost::python::numpy::ndarray::get_data(void)const " (__imp_?get_data@ndarray@numpy@python@boost@@QEBAPEADXZ),该符号在函数 "class boost::python::numpy::ndarray __cdecl forward(class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,double,double)" (?forward@@YA?AVndarray@numpy@python@boost@@V1234@00NN@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl boost::python::numpy::ndarray::~ndarray(void)" (__imp_??1ndarray@numpy@python@boost@@QEAA@XZ),该符号在函数 "class boost::python::numpy::ndarray __cdecl forward(class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,double,double)" (?forward@@YA?AVndarray@numpy@python@boost@@V1234@00NN@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl boost::python::numpy::ndarray::ndarray(class boost::python::numpy::ndarray &&)" (__imp_??0ndarray@numpy@python@boost@@QEAA@$$QEAV0123@@Z),该符号在函数 "class boost::python::numpy::ndarray __cdecl forward(class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,double,double)" (?forward@@YA?AVndarray@numpy@python@boost@@V1234@00NN@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) class boost::python::numpy::ndarray __cdecl boost::python::numpy::zeros(int,__int64 const *,class boost::python::numpy::dtype const &)" (__imp_?zeros@numpy@python@boost@@YA?AVndarray@123@HPEB_JAEBVdtype@123@@Z),该符号在函数 "class boost::python::numpy::ndarray __cdecl forward(class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,class boost::python::numpy::ndarray,double,double)" (?forward@@YA?AVndarray@numpy@python@boost@@V1234@00NN@Z) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static bool __cdecl boost::python::converter::object_manager_traits<class boost::python::numpy::ndarray>::check(struct _object *)" (__imp_?check@?$object_manager_traits@Vndarray@numpy@python@boost@@@converter@python@boost@@SA_NPEAU_object@@@Z),该符号在函数 "public: bool __cdecl boost::python::converter::object_manager_value_arg_from_python<class boost::python::numpy::ndarray>::convertible(void)const " (?convertible@?$object_manager_value_arg_from_python@Vndarray@numpy@python@boost@@@converter@python@boost@@QEBA_NXZ) 中被引用
4>pytoolbox.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static struct _typeobject const * __cdecl boost::python::converter::object_manager_traits<class boost::python::numpy::ndarray>::get_pytype(void)" (__imp_?get_pytype@?$object_manager_traits@Vndarray@numpy@python@boost@@@converter@python@boost@@SAPEBU_typeobject@@XZ),该符号在函数 "public: static struct _typeobject const * __cdecl boost::python::detail::object_manager_get_pytype<1>::get<class boost::python::numpy::ndarray>(class boost::python::numpy::ndarray const & (__cdecl*)(void))" (??$get@Vndarray@numpy@python@boost@@@?$object_manager_get_pytype@$00@detail@python@boost@@SAPEBU_typeobject@@P6AAEBVndarray@numpy@23@XZ@Z) 中被引用
4>E:\M256test\simulation_toolbox\build\Debug\pytoolbox.pyd : fatal error LNK1120: 14 个无法解析的外部命令
代码原来是ubuntu系统上编写的,跨平台重新编译,cmake没有报错没有waring,生成解决方案一直报“error LNK2019: 无法解析的外部符号”,查看了一些帖子尝试以下方式仍未解决:
- 添加库目录和库
看报错应该是boost:python和boost:nump这两个库相关,将两个库:
D:\software\boost_1_79_0\boost_1_79_0\lib\libboost_python37-vc142-mt-gd-x64-1_79.lib
D:\software\boost_1_79_0\boost_1_79_0\lib\libboost_numpy37-vc142-mt-gd-x64-1_79.lib
添加完链接器、常规、附加库目录和链接器、输入、附加依赖项,未解决; - 修改解决方案配置
因为cmakelists中指定为degug x64,所以按照要求重新生成,仍报错; - 查看代码具体报错为,看是否定义该函数或符号
查看所有报错位置,该函数均已经定义 - lib文件添加目录可能不对
查看正确
给下可能的问题方向,感谢。
大ge们可以说的清楚一些嘛,不要纯专业术语。