[C++-sig] linking problems with gcc and embedded python

chip chip at force-elite.com
Fri May 23 06:04:11 CEST 2003


First off, this code works fine in Windows using VC++ v6. (the pinnacle of all
compilers! (hehe))

This error reproduces in gcc 3.0.2(redhat 7.2) and 3.2.2(redhat 9.0).

We are using boost 1.29.0. Upgrading to the latest CVS would be possible if it
will fix this, but we would prefer not to have to go this route.(pain,
suffering, death... etc)

We are in the process of adding an embedded python interpreter to one of our
server programs.

We have built a boost python shared object that we dynamicly link to in our
servers.  It seems to work fine for other things.

Here are the linking errors we get: (be prepared... its ugly..)

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python6detail17make_function_auxIM11pyPythonMsgFSsvENS0_21default_call_policiesENS1_16args_from_pythonENS_3mpl5list2ISsRS3_EENS8_5int_cILi0EEEEENS0_3api6objectET_RKT0_RKT1_RKT2_RKSt4pairIPKNS1_7keywordEST_ET3_+0x4d):
In function `boost::python::api::object
boost::python::detail::make_function_aux<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > (pyPythonMsg::*)(),
boost::python::default_call_policies, boost::python::detail::args_from_python,
boost::mpl::list2<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, pyPythonMsg&>, boost::mpl::int_c<(int)0>
>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >
(pyPythonMsg::*)(), boost::python::default_call_policies const&,
boost::python::detail::args_from_python const&,
boost::mpl::list2<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, pyPythonMsg&> const&,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&, boost::mpl::int_c<(int)0>)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/function/function_base.hpp:246:
undefined reference to
`boost::python::objects::function_object(boost::function2<_object*, _object*,
_object*, std::allocator<boost::function_base> > const&, unsigned,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&)'

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python6detail17make_function_auxIM11pyPythonMsgFvSsENS0_21default_call_policiesENS1_16args_from_pythonENS_3mpl5list3IvRS3_SsEENS8_5int_cILi0EEEEENS0_3api6objectET_RKT0_RKT1_RKT2_RKSt4pairIPKNS1_7keywordEST_ET3_+0x4d):
In function `boost::python::api::object
boost::python::detail::make_function_aux<void
(pyPythonMsg::*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >), boost::python::default_call_policies,
boost::python::detail::args_from_python, boost::mpl::list3<void, pyPythonMsg&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
boost::mpl::int_c<(int)0> >(void (pyPythonMsg::*)(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >),
boost::python::default_call_policies const&,
boost::python::detail::args_from_python const&, boost::mpl::list3<void,
pyPythonMsg&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > const&, std::pair<boost::python::detail::keyword
const*, boost::python::detail::keyword const*> const&,
boost::mpl::int_c<(int)0>)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/function/function_base.hpp:246:
undefined reference to
`boost::python::objects::function_object(boost::function2<_object*, _object*,
_object*, std::allocator<boost::function_base> > const&, unsigned,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&)'

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python6detail17make_function_auxIM11pyPythonMsgFivENS0_21default_call_policiesENS1_16args_from_pythonENS_3mpl5list2IiRS3_EENS8_5int_cILi0EEEEENS0_3api6objectET_RKT0_RKT1_RKT2_RKSt4pairIPKNS1_7keywordEST_ET3_+0x4d):
In function `boost::python::api::object
boost::python::detail::make_function_aux<int (pyPythonMsg::*)(),
boost::python::default_call_policies, boost::python::detail::args_from_python,
boost::mpl::list2<int, pyPythonMsg&>, boost::mpl::int_c<(int)0> >(int
(pyPythonMsg::*)(), boost::python::default_call_policies const&,
boost::python::detail::args_from_python const&, boost::mpl::list2<int,
pyPythonMsg&> const&, std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&, boost::mpl::int_c<(int)0>)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/function/function_base.hpp:246:
undefined reference to
`boost::python::objects::function_object(boost::function2<_object*, _object*,
_object*, std::allocator<boost::function_base> > const&, unsigned,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&)'

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python6detail17make_function_auxIM11pyPythonMsgFvP5pyKeyENS0_21default_call_policiesENS1_16args_from_pythonENS_3mpl5list3IvRS3_S5_EENSA_5int_cILi0EEEEENS0_3api6objectET_RKT0_RKT1_RKT2_RKSt4pairIPKNS1_7keywordESV_ET3_+0x4d):
In function `boost::python::api::object
boost::python::detail::make_function_aux<void (pyPythonMsg::*)(pyKey*),
boost::python::default_call_policies, boost::python::detail::args_from_python,
boost::mpl::list3<void, pyPythonMsg&, pyKey*>, boost::mpl::int_c<(int)0>
>(void (pyPythonMsg::*)(pyKey*), boost::python::default_call_policies const&,
boost::python::detail::args_from_python const&, boost::mpl::list3<void,
pyPythonMsg&, pyKey*> const&, std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&, boost::mpl::int_c<(int)0>)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/function/function_base.hpp:246:
undefined reference to
`boost::python::objects::function_object(boost::function2<_object*, _object*,
_object*, std::allocator<boost::function_base> > const&, unsigned,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&)'

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python6detail17make_function_auxIM11pyPythonMsgFviENS0_21default_call_policiesENS1_16args_from_pythonENS_3mpl5list3IvRS3_iEENS8_5int_cILi0EEEEENS0_3api6objectET_RKT0_RKT1_RKT2_RKSt4pairIPKNS1_7keywordEST_ET3_+0x4d):
In function `boost::python::api::object
boost::python::detail::make_function_aux<void (pyPythonMsg::*)(int),
boost::python::default_call_policies, boost::python::detail::args_from_python,
boost::mpl::list3<void, pyPythonMsg&, int>, boost::mpl::int_c<(int)0> >(void
(pyPythonMsg::*)(int), boost::python::default_call_policies const&,
boost::python::detail::args_from_python const&, boost::mpl::list3<void,
pyPythonMsg&, int> const&, std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&, boost::mpl::int_c<(int)0>)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/function/function_base.hpp:246:
undefined reference to
`boost::python::objects::function_object(boost::function2<_object*, _object*,
_object*, std::allocator<boost::function_base> > const&, unsigned,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&)'

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python6detail17make_function_auxIPFP7_objectRK5pyKeyS7_ENS0_21default_call_policiesENS1_16args_from_pythonENS_3mpl5list3IS4_S7_S7_EENSC_5int_cILi0EEEEENS0_3api6objectET_RKT0_RKT1_RKT2_RKSt4pairIPKNS1_7keywordESW_ET3_+0x3e):../../../../Sources/Plasma/PubUtilLib/plNetCommon/plNetCommon.h:141:
more undefined references to
`boost::python::objects::function_object(boost::function2<_object*, _object*,
_object*, std::allocator<boost::function_base> > const&, unsigned,
std::pair<boost::python::detail::keyword const*,
boost::python::detail::keyword const*> const&)' follow
../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python7objects13make_instanceI5pyKeyNS1_14pointer_holderISt8auto_ptrIS3_ES3_EEE7executeIS6_EEP7_objectRT_+0x11):
In function `_object* boost::python::objects::make_instance<pyKey,
boost::python::objects::pointer_holder<std::auto_ptr<pyKey>, pyKey>
>::execute<std::auto_ptr<pyKey> >(std::auto_ptr<pyKey>&)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/python/errors.hpp:46:
undefined reference to
`boost::python::converter::registration::get_class_object() const'

../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python7objects13make_instanceI5pyKeyNS1_12value_holderIS3_EEE7executeIKNS_17reference_wrapperIKS3_EEEEP7_objectRT_+0x11):
In function `_object* boost::python::objects::make_instance<pyKey,
boost::python::objects::value_holder<pyKey>
>::execute<boost::reference_wrapper<pyKey const>
const>(boost::reference_wrapper<pyKey const> const&)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/python/errors.hpp:46:
undefined reference to
`boost::python::converter::registration::get_class_object() const'
../../../../UnixProjects/Plasma/Apps/plNetGameServer/plNetGameServer.dbg.lib.a(pyPythonMsg.dbg.o)(.gnu.linkonce.t._ZN5boost6python7objects13make_instanceI11pyPythonMsgNS1_12value_holderIS3_EEE7executeIKNS_17reference_wrapperIKS3_EEEEP7_objectRT_+0x11):
In function `_object* boost::python::objects::make_instance<pyPythonMsg,
boost::python::objects::value_holder<pyPythonMsg>
>::execute<boost::reference_wrapper<pyPythonMsg const>
const>(boost::reference_wrapper<pyPythonMsg const> const&)':
../../../../../StaticSDKs/XPlatform/boost_1_29_0/boost/python/errors.hpp:46:
undefined reference to
`boost::python::converter::registration::get_class_object() const'

sniplet of part of the offending code:

void pyPythonMsg::PythonModDef()
{
        class_<pyPythonMsg>("ptPythonMsg", init<>())
                .def("getContents",&pyPythonMsg::GetMsgContents)
                .def("setContents",&pyPythonMsg::SetMsgContents)
                .def("getSenderID",&pyPythonMsg::GetSenderID)
               
.def("getKey",&pyPythonMsg::GetKey,return_value_policy<manage_new_object>())
                .def("setKey",&pyPythonMsg::SetKey)
                .def("send",&pyPythonMsg::SendMessage)
        ;
        pyKey::PythonModDef();
}

If the defs are commented out, we do not get these linking errors.  The same
code works great under windows and VC++. The code without the embedded python
interpreter also works under both Windows and Linux.

I have been looking over these errors, but I can't seem to find anything
obvious that would be causing them.  For example, we aren't missing other
boost python functions, the linker seems to find them, but somthing about
these defs are causing the linker to not see the boost functions. We have
tried quote a few variations, recompiled boost a couple times, linked to debug
/nondebug.. etc., but can't seem to find anything that is causing this.

Because of the nature of this server, I cannot release a full copy of its
source for outside developers to test it. Sorry about that.  

Any pointers or possible solutions, no matter how faint of a chance, would be
greatly appreciated.

-chip

Cyan Worlds: http://www.cyanworlds.com
Cyan Worlds Open Source: http://open.cyanworlds.com




More information about the Cplusplus-sig mailing list