Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
785 views
in Technique[技术] by (71.8m points)

undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE: when importing c++ methods though python

I'm trying to write some simple c++ objects that I would like to expose in python. Following bit of instructions on Extending to python3 from boost python, I have the following -

#include <boost/python.hpp>

int someint() {
    return 0;
}

BOOST_PYTHON_MODULE(cpp_mod)
{
    using namespace boost::python;
    def("someint", someint);
}

adding as the python module, in setup.py.

from distutils.core import setup, Extension

example_module = Extension(
    'pyobj',
    sources=['pyobject.cpp'],
    language='C++', )

setup(
    name='pyobj',
    version='0.1.0',
    description='example module written in C++',
    ext_modules=[example_module], ) 

results in

>> import example
ImportError: /usr/local/lib/python3.8/dist-packages/example.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE

----

compling with g++, results in

g++ -I /usr/include/python3.8 pyobj.cpp

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `PyInit_hello_ext':
test.cpp:(.text+0x9d): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `_Py_DECREF':
test.cpp:(.text._Py_DECREF[_ZN5boost6python3api11object_baseD5Ev]+0x3e): undefined reference to `_Py_Dealloc'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::type_info::name() const':
test.cpp:(.text._ZNK5boost6python9type_info4nameEv[_ZNK5boost6python9type_info4nameEv]+0x23): undefined reference to `boost::python::detail::gcc_demangle(char const*)'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::to_python_value<int const&>::operator()(int const&) const':
test.cpp:(.text._ZNK5boost6python15to_python_valueIRKiEclES3_[_ZNK5boost6python15to_python_valueIRKiEclES3_]+0x20): undefined reference to `PyLong_FromLong'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::to_python_value<int const&>::get_pytype() const':
test.cpp:(.text._ZNK5boost6python15to_python_valueIRKiE10get_pytypeEv[_ZNK5boost6python15to_python_valueIRKiE10get_pytypeEv]+0xf): undefined reference to `PyLong_Type'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::api::object::object()':
test.cpp:(.text._ZN5boost6python3api6objectC2Ev[_ZN5boost6python3api6objectC5Ev]+0x18): undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `void boost::python::def<int (*)()>(char const*, int (*)())':
test.cpp:(.text._ZN5boost6python3defIPFivEEEvPKcT_[_ZN5boost6python3defIPFivEEEvPKcT_]+0x54): undefined reference to `boost::python::detail::scope_setattr_doc(char const*, boost::python::api::object const&, char const*)'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::api::object boost::python::detail::make_function_aux<int (*)(), boost::python::default_call_policies, boost::mpl::vector1<int> >(int (*)(), boost::python::default_call_policies const&, boost::mpl::vector1<int> const&)':
test.cpp:(.text._ZN5boost6python6detail17make_function_auxIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEENS0_3api6objectET_RKT0_RKT1_[_ZN5boost6python6detail17make_function_auxIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEENS0_3api6objectET_RKT0_RKT1_]+0x61): undefined reference to `boost::python::objects::function_object(boost::python::objects::py_function const&)'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::objects::py_function_impl_base::py_function_impl_base()':
test.cpp:(.text._ZN5boost6python7objects21py_function_impl_baseC2Ev[_ZN5boost6python7objects21py_function_impl_baseC5Ev]+0xf): undefined reference to `vtable for boost::python::objects::py_function_impl_base'
/usr/bin/ld: /tmp/ccBDVo8E.o:(.data.rel.ro._ZTVN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEEE[_ZTVN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEEE]+0x30): undefined reference to `boost::python::objects::py_function_impl_base::max_arity() const'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::objects::caller_py_function_impl<boost::python::detail::caller<int (*)(), boost::python::default_call_policies, boost::mpl::vector1<int> > >::~caller_py_function_impl()':
test.cpp:(.text._ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEED2Ev[_ZN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEED5Ev]+0x26): undefined reference to `boost::python::objects::py_function_impl_base::~py_function_impl_base()'
/usr/bin/ld: /tmp/ccBDVo8E.o:(.data.rel.ro._ZTIN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEEE[_ZTIN5boost6python7objects23caller_py_function_implINS0_6detail6callerIPFivENS0_21default_call_policiesENS_3mpl7vector1IiEEEEEE]+0x10): undefined reference to `typeinfo for boost::python::objects::py_function_impl_base'
/usr/bin/ld: /tmp/ccBDVo8E.o: in function `boost::python::converter::expected_pytype_for_arg<int>::get_pytype()':
test.cpp:(.text._ZN5boost6python9converter23expected_pytype_for_argIiE10get_pytypeEv[_ZN5boost6python9converter23expected_pytype_for_argIiE10get_pytypeEv]+0x1f): undefined reference to `boost::python::converter::registry::query(boost::python::type_info)'
/usr/bin/ld: test.cpp:(.text._ZN5boost6python9converter23expected_pytype_for_argIiE10get_pytypeEv[_ZN5boost6python9converter23expected_pytype_for_argIiE10get_pytypeEv]+0x36): undefined reference to `boost::python::converter::registration::expected_from_python_type() const'
collect2: error: ld returned 1 exit status

I don't understand the reason behind neither the first problem nor the latter.

question from:https://stackoverflow.com/questions/66047673/undefined-symbol-ztvn10-cxxabiv120-si-class-type-infoe-when-importing-c-m

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...