I'm trying to compile the example from the Boost Python docs without success.
hello.cpp: #include <boost/python.hpp> char const * const greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } I have Boost 1.48, Python 2.7, and gcc 4.7.0. When I do this: g++ -fPIC -I/usr/include/python2.7 -c -o hello.o hello.cpp I get the following errors: In file included from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:47:0, from /usr/include/boost/python/detail/invoke.hpp:63, from /usr/include/boost/python/detail/caller.hpp:16, from /usr/include/boost/python/object/function_handle.hpp:8, from /usr/include/boost/python/converter/arg_to_python.hpp:19, from /usr/include/boost/python/call.hpp:15, from /usr/include/boost/python/object_core.hpp:14, from /usr/include/boost/python/args.hpp:25, from /usr/include/boost/python.hpp:11, from hello.cpp:1: /usr/include/boost/python/detail/invoke.hpp: In instantiation of âPyObject* boost::python::detail::invoke(boost::python::detail::invoke_tag_<false, false>, const RC&, F&) [with RC = boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<const char* const>; F = const char* const (*)(); PyObject = _object]â: /usr/include/boost/python/detail/caller.hpp:223:13: required from âPyObject* boost::python::detail::caller_arity<0u>::impl<F, Policies, Sig>::operator()(PyObject*, PyObject*) [with F = const char* const (*)(); Policies = boost::python::default_call_policies; Sig = boost::mpl::vector1<const char* const>; PyObject = _object]â /usr/include/boost/python/object/py_function.hpp:38:33: required from âPyObject* boost::python::objects::caller_py_function_impl<Caller>::operator()(PyObject*, PyObject*) [with Caller = boost::python::detail::caller<const char* const (*)(), boost::python::default_call_policies, boost::mpl::vector1<const char* const> >; PyObject = _object]â hello.cpp:10:1: required from here /usr/include/boost/python/detail/invoke.hpp:75:19: error: no match for call to â(const boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<const char* const>) (const char*)â In file included from /usr/include/boost/python/object/function_handle.hpp:8:0, from /usr/include/boost/python/converter/arg_to_python.hpp:19, from /usr/include/boost/python/call.hpp:15, from /usr/include/boost/python/object_core.hpp:14, from /usr/include/boost/python/args.hpp:25, from /usr/include/boost/python.hpp:11, from hello.cpp:1: /usr/include/boost/python/detail/caller.hpp: In instantiation of âstatic const PyTypeObject* boost::python::detail::converter_target_type<ResultConverter>::get_pytype() [with ResultConverter = boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<const char* const>; PyTypeObject = _typeobject]â: /usr/include/boost/python/detail/caller.hpp:242:13: required from âstatic boost::python::detail::py_func_sig_info boost::python::detail::caller_arity<0u>::impl<F, Policies, Sig>::signature() [with F = const char* const (*)(); Policies = boost::python::default_call_policies; Sig = boost::mpl::vector1<const char* const>]â /usr/include/boost/python/object/py_function.hpp:48:35: required from âboost::python::detail::py_func_sig_info boost::python::objects::caller_py_function_impl<Caller>::signature() const [with Caller = boost::python::detail::caller<const char* const (*)(), boost::python::default_call_policies, boost::mpl::vector1<const char* const> >]â hello.cpp:10:1: required from here /usr/include/boost/python/detail/caller.hpp:102:109: error: âstruct boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<const char* const>â has no member named âget_pytypeâ In file included from /usr/include/boost/python/converter/pytype_function.hpp:10:0, from /usr/include/boost/python/to_python_indirect.hpp:16, from /usr/include/boost/python/converter/arg_to_python.hpp:10, from /usr/include/boost/python/call.hpp:15, from /usr/include/boost/python/object_core.hpp:14, from /usr/include/boost/python/args.hpp:25, from /usr/include/boost/python.hpp:11, from hello.cpp:1: /usr/include/boost/python/detail/unwind_type.hpp: In instantiation of âtypename Generator::result_type boost::python::detail::unwind_type(boost::type<U>*, Generator*) [with Generator = boost::python::converter::detail::unwind_type_id_helper; U = const char* const; typename Generator::result_type = boost::python::type_info]â: /usr/include/boost/python/converter/pytype_function.hpp:45:74: required from âboost::python::type_info boost::python::converter::detail::unwind_type_id_(boost::type<T>*, mpl_::false_*) [with T = const char* const; mpl_::false_ = mpl_::bool_<false>]â /usr/include/boost/python/converter/pytype_function.hpp:68:13: required from âstatic const PyTypeObject* boost::python::converter::expected_pytype_for_arg<T>::get_pytype() [with T = const char* const; PyTypeObject = _typeobject]â /usr/include/boost/python/detail/signature.hpp:98:13: required from âstatic const boost::python::detail::signature_element* boost::python::detail::signature_arity<0u>::impl<Sig>::elements() [with Sig = boost::mpl::vector1<const char* const>]â /usr/include/boost/python/detail/caller.hpp:232:78: required from âstatic boost::python::detail::py_func_sig_info boost::python::detail::caller_arity<0u>::impl<F, Policies, Sig>::signature() [with F = const char* const (*)(); Policies = boost::python::default_call_policies; Sig = boost::mpl::vector1<const char* const>]â /usr/include/boost/python/object/py_function.hpp:48:35: required from âboost::python::detail::py_func_sig_info boost::python::objects::caller_py_function_impl<Caller>::signature() const [with Caller = boost::python::detail::caller<const char* const (*)(), boost::python::default_call_policies, boost::mpl::vector1<const char* const> >]â hello.cpp:10:1: required from here /usr/include/boost/python/detail/unwind_type.hpp:165:72: error: no matching function for call to âboost::python::detail::unwind_helper2<1>::execute(const char* const (*)(), boost::python::converter::detail::unwind_type_id_helper*)â /usr/include/boost/python/detail/unwind_type.hpp:165:72: note: candidate is: In file included from /usr/include/boost/python/converter/pytype_function.hpp:10:0, from /usr/include/boost/python/to_python_indirect.hpp:16, from /usr/include/boost/python/converter/arg_to_python.hpp:10, from /usr/include/boost/python/call.hpp:15, from /usr/include/boost/python/object_core.hpp:14, from /usr/include/boost/python/args.hpp:25, from /usr/include/boost/python.hpp:11, from hello.cpp:1: /usr/include/boost/python/detail/unwind_type.hpp:114:5: note: template<class Generator, class U> static typename Generator::result_type boost::python::detail::unwind_helper2<1>::execute(U* (*)(), Generator*) /usr/include/boost/python/detail/unwind_type.hpp:114:5: note: template argument deduction/substitution failed: In file included from /usr/include/boost/python/converter/pytype_function.hpp:10:0, from /usr/include/boost/python/to_python_indirect.hpp:16, from /usr/include/boost/python/converter/arg_to_python.hpp:10, from /usr/include/boost/python/call.hpp:15, from /usr/include/boost/python/object_core.hpp:14, from /usr/include/boost/python/args.hpp:25, from /usr/include/boost/python.hpp:11, from hello.cpp:1: /usr/include/boost/python/detail/unwind_type.hpp:165:72: note: types âU*â and âconst char* constâ have incompatible cv-qualifiers It looks like the salient error is this one: /usr/include/boost/python/detail/invoke.hpp:75:19: error: no match for call to â(const boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<const char* const>) (const char*)â but the Boost Python tutorial didn't mention the need to specify a return value policy for the "hello world" example. So, I suppose this is either a) a bug in Boost Python, b) a bug in the Boost Python tutorial I copied from, or c) a mistake I'm making Does anyone see which? -- J.
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig