Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to copile an example of how to create a module callable from python3.7.

I think i have done all the steps correctly but when compiling the project i'm getting
a lot of unresolved symbol errors (lnk2019).

The sources are very simple:

#include <iostream>
#define BOOST_PYTHON_STATIC_LIB    
#include <boost\python.hpp>

using namespace boost::python;

void sayHello()
{
	std::cout << "Hello, Python!\n";
}

BOOST_PYTHON_MODULE(mantid)  // Name here must match the name of the final shared library, i.e. mantid.dll or mantid.so
{
	boost::python::def("sayHello", &sayHello);
}



I think I have configured all the directories correctly


I have compiled using this .bat file


call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86
 
call bootstrap.bat
 
rem Most libraries can be static libs
b2 -j8 toolset=msvc-14.0 address-model=64 architecture=x86 --with-python install



[edit]
precisely 7 unresolved symbols (sorry for the ugly format deriving from copy and paste):

unresolved external symbol "class boost::python::api::object __cdecl boost::python::objects::function_object(struct boost::python::objects::py_function const &)" (?function_object@objects@python@boost@@YA?AVobject@api@23@AEBUpy_function@123@@Z)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	
unresolved external symbol "public: struct _typeobject const * __cdecl boost::python::converter::registration::expected_from_python_type(void)const " (?expected_from_python_type@registration@converter@python@boost@@QEBAPEBU_typeobject@@XZ)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	
unresolved external symbol "public: virtual unsigned int __cdecl boost::python::objects::py_function_impl_base::max_arity(void)const " (?max_arity@py_function_impl_base@objects@python@boost@@UEBAIXZ)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	
unresolved external symbol "public: virtual __cdecl boost::python::objects::py_function_impl_base::~py_function_impl_base(void)" (??1py_function_impl_base@objects@python@boost@@UEAA@XZ)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	
unresolved external symbol "struct boost::python::converter::registration const * __cdecl boost::python::converter::registry::query(struct boost::python::type_info)" (?query@registry@converter@python@boost@@YAPEBUregistration@234@Utype_info@34@@Z)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	
unresolved external symbol "struct _object * __cdecl boost::python::detail::init_module(struct PyModuleDef &,void (__cdecl*)(void))" (?init_module@detail@python@boost@@YAPEAU_object@@AEAUPyModuleDef@@P6AXXZ@Z)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	
unresolved external symbol "void __cdecl boost::python::detail::scope_setattr_doc(char const *,class boost::python::api::object const &,char const *)" (?scope_setattr_doc@detail@python@boost@@YAXPEBDAEBVobject@api@23@0@Z)	BoostPython	C:\work\VC++ Projects\BoostPython\BoostPython\main.obj	1	Build	

[/edit]

What I have tried:

I tried everything but i really can't compile the project.

What I am missing?
Posted
Updated 13-Feb-20 2:36am
v2
Comments
Richard MacCutchan 13-Feb-20 7:28am    
"a lot of unresolved symbol errors"
What are they?
Optimistic76 13-Feb-20 7:49am    
precisely 7 unresolved symbols (sorry for the ugly format deriving from copy and paste):

unresolved external symbol "class boost::python::api::object __cdecl boost::python::objects::function_object(struct boost::python::objects::py_function const &)" (?function_object@objects@python@boost@@YA?AVobject@api@23@AEBUpy_function@123@@Z) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
unresolved external symbol "public: struct _typeobject const * __cdecl boost::python::converter::registration::expected_from_python_type(void)const " (?expected_from_python_type@registration@converter@python@boost@@QEBAPEBU_typeobject@@XZ) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
unresolved external symbol "public: virtual unsigned int __cdecl boost::python::objects::py_function_impl_base::max_arity(void)const " (?max_arity@py_function_impl_base@objects@python@boost@@UEBAIXZ) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
unresolved external symbol "public: virtual __cdecl boost::python::objects::py_function_impl_base::~py_function_impl_base(void)" (??1py_function_impl_base@objects@python@boost@@UEAA@XZ) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
unresolved external symbol "struct boost::python::converter::registration const * __cdecl boost::python::converter::registry::query(struct boost::python::type_info)" (?query@registry@converter@python@boost@@YAPEBUregistration@234@Utype_info@34@@Z) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
unresolved external symbol "struct _object * __cdecl boost::python::detail::init_module(struct PyModuleDef &,void (__cdecl*)(void))" (?init_module@detail@python@boost@@YAPEAU_object@@AEAUPyModuleDef@@P6AXXZ@Z) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
unresolved external symbol "void __cdecl boost::python::detail::scope_setattr_doc(char const *,class boost::python::api::object const &,char const *)" (?scope_setattr_doc@detail@python@boost@@YAXPEBDAEBVobject@api@23@0@Z) BoostPython C:\work\VC++ Projects\BoostPython\BoostPython\main.obj 1 Build
Richard MacCutchan 13-Feb-20 8:34am    
You are missing a library reference in your build. Check which boost library (or libraries) contains the definitions for all those references and add it to the project.
Optimistic76 13-Feb-20 9:28am    
I don't think this is the case. I already added all the references but the errors still appears
Richard MacCutchan 13-Feb-20 10:04am    
Well, you are either missing a reference, or calling out to external functions which do not exist. In either case you need to check the boost documentation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900