From babakage at gmail.com Mon Apr 2 23:59:47 2012 From: babakage at gmail.com (babak) Date: Mon, 2 Apr 2012 14:59:47 -0700 (PDT) Subject: [C++-sig] wrapped std::vector slice affecting items in a python list In-Reply-To: References: <1313148516764-3738972.post@n4.nabble.com> <4E457F72.3020004@gmail.com> <1313505161303-3747397.post@n4.nabble.com> <4E4AAA67.4060909@gmail.com> <4E4AD5E2.9070500@gmail.com> Message-ID: <1333403987047-4527267.post@n4.nabble.com> Hi, Thought you might be interested to know that I think the cause of the problem in my example is the iter method that the indexing suite adds. Unlike getitem it doesn't seem to return proxy objects, so when I slice insert into the cpp container some of the references made by iterating through it change, instead of becoming detached. babak -- View this message in context: http://boost.2283326.n4.nabble.com/wrapped-std-vector-slice-affecting-items-in-a-python-list-tp3738972p4527267.html Sent from the Python - c++-sig mailing list archive at Nabble.com. From payaam.shivaa at gmail.com Tue Apr 3 11:12:48 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Tue, 3 Apr 2012 13:42:48 +0430 Subject: [C++-sig] Problem Compiling Boost.Python Example Message-ID: Hi, I have trouble compiling the simplest examples with Boost.Python. I hope you could help me find out what I'm doing wrong. I am using Microsoft Visual C++ 2010 on 64-bit Windows 7. I use 64-bit version of Python 2.7.2 from Enthought Python Distribution 7.2-2. I installed Boost as described in "Simplified Build From Source" section of Boost getting started guide, i.e. going to Boost.Build directory and typing: bootstarp .\b2 Boost compiled without errors (except for a warning about MPI). Then I created user-config.jam in my home directory containing the following lines: using msvc : 10.0 ; using python : 2.7 : C:\\Python 27 ; Then I tried compiling the tutorial example, but I got the following messages (and no DLL): C:\Boost\boost_1_49_0\libs\python\example\tutorial> bjam ...patience... ...patience... ...found 1592 targets... ...updating 10 targets... msvc.link.dll ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.dll Creating library ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.l ib and object ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.exp function.obj : error LNK2001: unresolved external symbol __imp__PyErr_Format numeric.obj : error LNK2019: unresolved external symbol __imp__PyErr_Format referenced in function "void __cdecl boost:: python::numeric::`anonymous namespace'::throw_load_failure(void)" (?throw_load_failure@?A0xd5ad2121 at numeric@python at boost @@YAXXZ) from_python.obj : error LNK2001: unresolved external symbol __imp__PyErr_Format registry.obj : error LNK2001: unresolved external symbol __imp__PyErr_Format class.obj : error LNK2001: unresolved external symbol __imp__PyErr_Format numeric.obj : error LNK2001: unresolved external symbol __imp__PyExc_ImportError numeric.obj : error LNK2019: unresolved external symbol __imp__PyErr_Clear referenced in function "bool __cdecl boost::p ython::numeric::`anonymous namespace'::load(bool)" (?load@?A0xd5ad2121 at numeric@python at boost@@YA_N_N at Z) class.obj : error LNK2001: unresolved external symbol __imp__PyErr_Clear function.obj : error LNK2001: unresolved external symbol __imp__PyErr_Clear object_protocol.obj : error LNK2001: unresolved external symbol __imp__PyErr_Clear numeric.obj : error LNK2019: unresolved external symbol __imp__PyCallable_Check referenced in function "bool __cdecl boo st::python::numeric::`anonymous namespace'::load(bool)" (?load@?A0xd5ad2121 at numeric@python at boost@@YA_N_N at Z) class.obj : error LNK2001: unresolved external symbol __imp__PyCallable_Check object_protocol.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetAttrString wrapper.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetAttrString numeric.obj : error LNK2019: unresolved external symbol __imp__PyObject_GetAttrString referenced in function "bool __cde cl boost::python::numeric::`anonymous namespace'::load(bool)" (?load@?A0xd5ad2121 at numeric@python at boost@@YA_N_N at Z) enum.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetAttrString class.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetAttrString function.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetAttrString numeric.obj : error LNK2019: unresolved external symbol __imp__PyImport_Import referenced in function "bool __cdecl boos t::python::numeric::`anonymous namespace'::load(bool)" (?load@?A0xd5ad2121 at numeric@python at boost@@YA_N_N at Z) numeric.obj : error LNK2019: unresolved external symbol __imp__PyObject_IsInstance referenced in function "public: stati c bool __cdecl boost::python::numeric::aux::array_object_manager_traits::check(struct _object *)" (?check at array_object_m anager_traits at aux@numeric at python@boost@@SA_NPAU_object@@@Z) from_python.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsInstance class.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsInstance enum.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction class.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction stl_iterator.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction numeric.obj : error LNK2019: unresolved external symbol __imp__PyEval_CallFunction referenced in function "class boost:: python::api::object __cdecl boost::python::call(struc t _object *,class boost::python::api::object const &,struct boost::type *)" (??$call at V object at api@python at boost@@V1234@@python at boost@@YA?AVobject at api@01 at PAU_object@@ABV2301 at PAU?$type at Vobject@api at python@boost@ @@1@@Z) list.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction dict.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction str.obj : error LNK2001: unresolved external symbol __imp__PyEval_CallFunction function.obj : error LNK2001: unresolved external symbol __imp__PyInt_FromLong function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyInt_FromLong numeric.obj : error LNK2019: unresolved external symbol __imp__PyInt_FromLong referenced in function "public: __thiscall boost::python::converter::arg_to_python::arg_to_python(long const &)" (??0?$arg_to_python at J@converter at pytho n at boost@@QAE at ABJ@Z) list.obj : error LNK2001: unresolved external symbol __imp__PyInt_FromLong enum.obj : error LNK2001: unresolved external symbol __imp__PyInt_FromLong class.obj : error LNK2001: unresolved external symbol __imp__PyInt_FromLong numeric.obj : error LNK2019: unresolved external symbol __imp__PyBool_FromLong referenced in function "public: __thiscal l boost::python::converter::arg_to_python::arg_to_python(bool const &)" (??0?$arg_to_python at _N@converter at pyt hon at boost@@QAE at AB_N@Z) class.obj : error LNK2001: unresolved external symbol __imp__PyBool_FromLong numeric.obj : error LNK2019: unresolved external symbol __imp__PyString_FromStringAndSize referenced in function "public : __thiscall boost::python::converter::arg_to_python,class st d::allocator > >::arg_to_python,class std::allocator > >(class std::basic_string,class std::allocator > const &)" (??0?$arg_to_p ython at V?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@@converter at python@boost@@QAE at ABV?$basic_string at DU?$c har_traits at D@std@@V?$allocator at D@2@@std@@@Z) str.obj : error LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize wrapper.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct import.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct exec.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct function_doc_signature.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct iterator.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct stl_iterator.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct object_protocol.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct object_operators.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct life_support.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct pickle_support.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct module.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct builtin_converters.obj : error LNK2019: unresolved external symbol __imp___Py_NoneStruct referenced in function "public: static void __cdecl boost::numeric::convdetail::generic_range_checker,struct boost::numeric::convdetail::LT_Zero >, struct boost::numeric::convdetail::GT_HiT >,struct boost:: numeric::def_overflow_handler>::validate_range(long)" (?validate_range@?$generic_range_checker at U?$conversion_traits at GJ@n umeric at boost@@U?$LT_Zero at U?$conversion_traits at GJ@numeric at boost@@@convdetail at 23@U?$GT_HiT at U?$conversion_traits at GJ@numeric @boost@@@523 at Udef_overflow_handler@23@@convdetail at numeric@boost@@SAXJ at Z) registry.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct enum.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct class.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct function.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct tuple.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct str.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct slice.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct from_python.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct numeric.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct list.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct long.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct dict.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct str.obj : error LNK2001: unresolved external symbol __imp__PyObject_CallFunction class.obj : error LNK2001: unresolved external symbol __imp__PyObject_CallFunction list.obj : error LNK2019: unresolved external symbol __imp__PyObject_CallFunction referenced in function "private: stati c struct boost::python::detail::new_non_null_reference_t * __cdecl boost::python::detail::list_base::call(class boost::p ython::api::object const &)" (?call at list_base@detail at python@boost@@CAPAUnew_non_null_reference_t at 234@ABVobject at api@34@@Z ) long.obj : error LNK2001: unresolved external symbol __imp__PyObject_CallFunction dict.obj : error LNK2001: unresolved external symbol __imp__PyObject_CallFunction tuple.obj : error LNK2001: unresolved external symbol __imp__PyObject_CallFunction list.obj : error LNK2001: unresolved external symbol __imp__PyList_Type list.obj : error LNK2019: unresolved external symbol __imp__PyList_New referenced in function "protected: __thiscall boo st::python::detail::list_base::list_base(void)" (??0list_base at detail@python at boost@@IAE at XZ) list.obj : error LNK2019: unresolved external symbol __imp__PyList_Append referenced in function "public: void __thiscal l boost::python::detail::list_base::append(class boost::python::api::object const &)" (?append at list_base@detail at python@b oost@@QAEXABVobject at api@34@@Z) list.obj : error LNK2019: unresolved external symbol __imp__PyInt_AsLong referenced in function "public: long __thiscall boost::python::detail::list_base::index(class boost::python::api::object const &)const " (?index at list_base@detail at pytho n at boost@@QBEJABVobject at api@34@@Z) str.obj : error LNK2001: unresolved external symbol __imp__PyInt_AsLong class.obj : error LNK2001: unresolved external symbol __imp__PyInt_AsLong builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyInt_AsLong list.obj : error LNK2019: unresolved external symbol __imp__PyList_Insert referenced in function "public: void __thiscal l boost::python::detail::list_base::insert(int,class boost::python::api::object const &)" (?insert at list_base@detail at pyth on at boost@@QAEXHABVobject at api@34@@Z) pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred stl_iterator.obj : error LNK2019: unresolved external symbol __imp__PyErr_Occurred referenced in function "public: __thi scall boost::python::handle::operator struct _object * (__thiscall boost::python::handle ::*)(void)const (void)const " (??B?$handle at U_object@@@python at boost@@QBEP8012 at BEPAU_object@@XZXZ) function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred list.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred str.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred enum.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred function.obj : error LNK2001: unresolved external symbol __imp__PyErr_Occurred list.obj : error LNK2019: unresolved external symbol __imp__PyList_Reverse referenced in function "public: void __thisca ll boost::python::detail::list_base::reverse(void)" (?reverse at list_base@detail at python@boost@@QAEXXZ) list.obj : error LNK2019: unresolved external symbol __imp__PyList_Sort referenced in function "public: void __thiscall boost::python::detail::list_base::sort(void)" (?sort at list_base@detail at python@boost@@QAEXXZ) long.obj : error LNK2001: unresolved external symbol __imp__PyLong_Type builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyLong_Type referenced in function "struct _ob ject * __cdecl boost::python::converter::do_return_to_python(char const *)" (?do_return_to_python at converter@python at boost @@YAPAU_object@@PBD at Z) dict.obj : error LNK2001: unresolved external symbol __imp__PyDict_Type enum.obj : error LNK2001: unresolved external symbol __imp__PyDict_Type dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_New referenced in function "protected: __thiscall boo st::python::detail::dict_base::dict_base(void)" (??0dict_base at detail@python at boost@@IAE at XZ) class.obj : error LNK2001: unresolved external symbol __imp__PyDict_New dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_Clear referenced in function "public: void __thiscall boost::python::detail::dict_base::clear(void)" (?clear at dict_base@detail at python@boost@@QAEXXZ) dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_Copy referenced in function "public: class boost::pyt hon::dict __thiscall boost::python::detail::dict_base::copy(void)" (?copy at dict_base@detail at python@boost@@QAE?AVdict at 34@X Z) dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_GetItem referenced in function "public: class boost:: python::api::object __thiscall boost::python::detail::dict_base::get(class boost::python::api::object const &)const " (? get at dict_base@detail at python@boost@@QBE?AVobject at api@34 at ABV5634@@Z) function.obj : error LNK2001: unresolved external symbol __imp__PyDict_GetItem dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_Items referenced in function "public: class boost::py thon::list __thiscall boost::python::detail::dict_base::items(void)const " (?items at dict_base@detail at python@boost@@QBE?AV list at 34@XZ) dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_Keys referenced in function "public: class boost::pyt hon::list __thiscall boost::python::detail::dict_base::keys(void)const " (?keys at dict_base@detail at python@boost@@QBE?AVlis t at 34@XZ) dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_Update referenced in function "public: void __thiscal l boost::python::detail::dict_base::update(class boost::python::api::object const &)" (?update at dict_base@detail at python@b oost@@QAEXABVobject at api@34@@Z) dict.obj : error LNK2019: unresolved external symbol __imp__PyDict_Values referenced in function "public: class boost::p ython::list __thiscall boost::python::detail::dict_base::values(void)const " (?values at dict_base@detail at python@boost@@QBE ?AVlist at 34@XZ) tuple.obj : error LNK2001: unresolved external symbol __imp__PyTuple_Type pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyTuple_Type function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyTuple_New tuple.obj : error LNK2019: unresolved external symbol __imp__PyTuple_New referenced in function "protected: __thiscall b oost::python::detail::tuple_base::tuple_base(void)" (??0tuple_base at detail@python at boost@@IAE at XZ) enum.obj : error LNK2001: unresolved external symbol __imp__PyTuple_New class.obj : error LNK2001: unresolved external symbol __imp__PyTuple_New function.obj : error LNK2001: unresolved external symbol __imp__PyTuple_New str.obj : error LNK2001: unresolved external symbol __imp__PyString_Type builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyString_Type referenced in function __unwindf unclet$?construct@?$slot_rvalue_from_python at _NUbool_rvalue_from_python@?A0xa22ba1ea at converter@python at boost@@@?A0xa22ba1e a at converter@python at boost@@CAXPAU_object@@PAUrvalue_from_python_stage1_data at 345@@Z$0 str.obj : error LNK2019: unresolved external symbol __imp__PyString_FromString referenced in function "protected: __this call boost::python::detail::str_base::str_base(void)" (??0str_base at detail@python at boost@@IAE at XZ) builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyString_FromString str.obj : error LNK2019: unresolved external symbol __imp__PyObject_CallMethod referenced in function "public: class boo st::python::str __thiscall boost::python::detail::str_base::capitalize(void)const " (?capitalize at str_base@detail at python@ boost@@QBE?AVstr at 34@XZ) slice.obj : error LNK2019: unresolved external symbol __imp__PySlice_New referenced in function "protected: __thiscall b oost::python::detail::slice_base::slice_base(struct _object *,struct _object *,struct _object *)" (??0slice_base at detail@ python at boost@@IAE at PAU_object@@00 at Z) object_protocol.obj : error LNK2001: unresolved external symbol __imp__PySlice_New pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetObject iterator.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetObject from_python.obj : error LNK2019: unresolved external symbol __imp__PyErr_SetObject referenced in function "void * __cdec l boost::python::converter::rvalue_from_python_stage2(struct _object *,struct boost::python::converter::rvalue_from_pyth on_stage1_data &,struct boost::python::converter::registration const &)" (?rvalue_from_python_stage2 at converter@python at bo ost@@YAPAXPAU_object@@AAUrvalue_from_python_stage1_data at 123@ABUregistration at 123@@Z) registry.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetObject class.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetObject function.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetObject from_python.obj : error LNK2001: unresolved external symbol __imp__PyExc_TypeError registry.obj : error LNK2019: unresolved external symbol __imp__PyExc_TypeError referenced in function "void __cdecl boo st::python::converter::registry::insert(struct _object * (__cdecl*)(void const *),struct boost::python::type_info,struct _typeobject const * (__cdecl*)(void))" (?insert at registry@converter at python@boost@@YAXP6APAU_object@@PBX at ZUtype_info@34 at P 6APBU_typeobject@@XZ at Z) class.obj : error LNK2001: unresolved external symbol __imp__PyExc_TypeError function.obj : error LNK2001: unresolved external symbol __imp__PyExc_TypeError from_python.obj : error LNK2019: unresolved external symbol __imp__PyString_FromFormat referenced in function "void * __ cdecl boost::python::converter::rvalue_from_python_stage2(struct _object *,struct boost::python::converter::rvalue_from_ python_stage1_data &,struct boost::python::converter::registration const &)" (?rvalue_from_python_stage2 at converter@pytho n at boost@@YAPAXPAU_object@@AAUrvalue_from_python_stage1_data at 123@ABUregistration at 123@@Z) registry.obj : error LNK2001: unresolved external symbol __imp__PyString_FromFormat enum.obj : error LNK2001: unresolved external symbol __imp__PyString_FromFormat from_python.obj : error LNK2001: unresolved external symbol __imp__PyExc_ReferenceError registry.obj : error LNK2019: unresolved external symbol __imp__PyErr_WarnEx referenced in function "void __cdecl boost: :python::converter::registry::insert(struct _object * (__cdecl*)(void const *),struct boost::python::type_info,struct _t ypeobject const * (__cdecl*)(void))" (?insert at registry@converter at python@boost@@YAXP6APAU_object@@PBX at ZUtype_info@34 at P6AP BU_typeobject@@XZ at Z) enum.obj : error LNK2019: unresolved external symbol __imp__PyString_AsString referenced in function _enum_repr builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyString_AsString enum.obj : error LNK2001: unresolved external symbol __imp__PyInt_Type builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyInt_Type referenced in function "private: st atic void __cdecl boost::python::converter::`anonymous namespace'::slot_rvalue_from_python::construct(struct _object *,struct boost::python::converter:: rvalue_from_python_stage1_data *)" (?construct@?$slot_rvalue_from_python at MUfloat_rvalue_from_python@?A0xa22ba1ea at convert er at python@boost@@@?A0xa22ba1ea at converter@python at boost@@CAXPAU_object@@PAUrvalue_from_python_stage1_data at 345@@Z) enum.obj : error LNK2019: unresolved external symbol __imp__PyType_Ready referenced in function "class boost::python::ap i::object __cdecl boost::python::objects::`anonymous namespace'::new_enum_type(char const *,char const *)" (?new_enum_ty pe@?A0xb5ee345a at objects@python at boost@@YA?AVobject at api@34 at PBD0@Z) class.obj : error LNK2001: unresolved external symbol __imp__PyType_Ready function.obj : error LNK2001: unresolved external symbol __imp__PyType_Ready life_support.obj : error LNK2001: unresolved external symbol __imp__PyType_Ready enum.obj : error LNK2001: unresolved external symbol __imp__PyType_Type class.obj : error LNK2001: unresolved external symbol __imp__PyType_Type function.obj : error LNK2001: unresolved external symbol __imp__PyType_Type life_support.obj : error LNK2001: unresolved external symbol __imp__PyType_Type function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyObject_Size enum.obj : error LNK2019: unresolved external symbol __imp__PyObject_Size referenced in function "int __cdecl boost::pyt hon::len(class boost::python::api::object const &)" (?len at python@boost@@YAHABVobject at api@12@@Z) function.obj : error LNK2001: unresolved external symbol __imp__PyObject_Size pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyObject_Size builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyObject_Size builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsTrue function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsTrue enum.obj : error LNK2019: unresolved external symbol __imp__PyObject_IsTrue referenced in function "public: __thiscall b oost::python::api::object_operators::operator struct _object * (__thiscall boost::pyth on::api::object::*)(void)const (void)const " (??B?$object_operators at Vobject@api at python@boost@@@api at python@boost@@QBEP8ob ject at 123@BEPAU_object@@XZXZ) class.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsTrue function.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsTrue pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyObject_IsTrue enum.obj : error LNK2019: unresolved external symbol __imp__PyLong_FromUnsignedLong referenced in function "public: __th iscall boost::python::converter::arg_to_python::arg_to_python(unsigned int const &)" (??0?$a rg_to_python at I@converter at python@boost@@QAE at ABI@Z) class.obj : error LNK2001: unresolved external symbol __imp__PyLong_FromUnsignedLong function.obj : error LNK2001: unresolved external symbol __imp__PyLong_FromUnsignedLong function_doc_signature.obj : error LNK2001: unresolved external symbol __imp__PyLong_FromUnsignedLong class.obj : error LNK2019: unresolved external symbol __imp__PyArg_ParseTupleAndKeywords referenced in function _propert y_init builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyErr_SetString referenced in function "privat e: static void __cdecl boost::python::converter::`anonymous namespace'::slot_rvalue_from_python,struct boost::python::converter::`anonymous namespace'::complex_rvalue_from_python>::construct(struct _object *,struct boost::python::converter::rvalue_from_python_stage1_data *)" (?construct@?$slot_rvalue_from_python at V?$complex at M@std@@Uc omplex_rvalue_from_python@?A0xa22ba1ea at converter@python at boost@@@?A0xa22ba1ea at converter@python at boost@@CAXPAU_object@@PAUr value_from_python_stage1_data at 345@@Z) class.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetString function.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetString pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetString errors.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetString class.obj : error LNK2001: unresolved external symbol __imp__PyExc_AttributeError function.obj : error LNK2001: unresolved external symbol __imp__PyExc_AttributeError object_protocol.obj : error LNK2001: unresolved external symbol __imp__PyExc_AttributeError class.obj : error LNK2001: unresolved external symbol __imp__PyProperty_Type class.obj : error LNK2019: unresolved external symbol __imp__PyType_IsSubtype referenced in function "public: void __thi scall boost::python::instance_holder::install(struct _object *)" (?install at instance_holder@python at boost@@QAEXPAU_object@ @@Z) builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyType_IsSubtype class.obj : error LNK2019: unresolved external symbol __imp__PyObject_ClearWeakRefs referenced in function _instance_dea lloc class.obj : error LNK2001: unresolved external symbol __imp__PyBaseObject_Type class.obj : error LNK2001: unresolved external symbol __imp__PyModule_Type class.obj : error LNK2001: unresolved external symbol __imp__PyExc_RuntimeError function.obj : error LNK2001: unresolved external symbol __imp__PyExc_RuntimeError pickle_support.obj : error LNK2001: unresolved external symbol __imp__PyExc_RuntimeError errors.obj : error LNK2001: unresolved external symbol __imp__PyExc_RuntimeError class.obj : error LNK2019: unresolved external symbol __imp__PyObject_SetAttrString referenced in function "protected: v oid __thiscall boost::python::objects::class_base::setattr(char const *,class boost::python::api::object const &)" (?set attr at class_base@objects at python@boost@@IAEXPBDABVobject at api@34@@Z) object_protocol.obj : error LNK2001: unresolved external symbol __imp__PyObject_SetAttrString class.obj : error LNK2019: unresolved external symbol __imp__PyCFunction_NewEx referenced in function "protected: void _ _thiscall boost::python::objects::class_base::def_no_init(void)" (?def_no_init at class_base@objects at python@boost@@IAEXXZ) class.obj : error LNK2019: unresolved external symbol __imp__PyStaticMethod_New referenced in function "protected: void __thiscall boost::python::objects::class_base::make_method_static(char const *)" (?make_method_static at class_base@objects @python at boost@@IAEXPBD at Z) class.obj : error LNK2019: unresolved external symbol __imp__PyMem_Malloc referenced in function "public: static void * __cdecl boost::python::instance_holder::allocate(struct _object *,unsigned int,unsigned int)" (?allocate at instance_holder @python at boost@@SAPAXPAU_object@@II at Z) class.obj : error LNK2019: unresolved external symbol __imp__PyMem_Free referenced in function "public: static void __cd ecl boost::python::instance_holder::deallocate(struct _object *,void *)" (?deallocate at instance_holder@python at boost@@SAXP AU_object@@PAX at Z) class.obj : error LNK2019: unresolved external symbol __imp___PyType_Lookup referenced in function _class_setattro class.obj : error LNK2019: unresolved external symbol __imp__PyType_GenericAlloc referenced in function "void __cdecl bo ost::python::objects::`dynamic initializer for 'class_type_object''(void)" (??__Eclass_type_object at objects@python at boost@ @YAXXZ) function.obj : error LNK2019: unresolved external symbol __imp__PyTuple_Size referenced in function "public: struct _obj ect * __thiscall boost::python::objects::function::call(struct _object *,struct _object *)const " (?call at function@object s at python@boost@@QBEPAU_object@@PAU5 at 0@Z) function.obj : error LNK2019: unresolved external symbol __imp__PyDict_Size referenced in function "public: struct _obje ct * __thiscall boost::python::objects::function::call(struct _object *,struct _object *)const " (?call at function@objects @python at boost@@QBEPAU_object@@PAU5 at 0@Z) function.obj : error LNK2019: unresolved external symbol __imp__PyTuple_GetItem referenced in function "private: void __ thiscall boost::python::objects::function::argument_error(struct _object *,struct _object *)const " (?argument_error at fun ction at objects@python at boost@@ABEXPAU_object@@0 at Z) function.obj : error LNK2019: unresolved external symbol __imp__PyErr_NewException referenced in function "private: void __thiscall boost::python::objects::function::argument_error(struct _object *,struct _object *)const " (?argument_error@ function at objects@python at boost@@ABEXPAU_object@@0 at Z) function.obj : error LNK2001: unresolved external symbol __imp___Py_NotImplementedStruct function.obj : error LNK2019: unresolved external symbol __imp__PyObject_SetAttr referenced in function "public: static void __cdecl boost::python::objects::function::add_to_namespace(class boost::python::api::object const &,char const *,cl ass boost::python::api::object const &,char const *)" (?add_to_namespace at function@objects at python@boost@@SAXABVobject at api @34 at PBD01@Z) object_protocol.obj : error LNK2001: unresolved external symbol __imp__PyObject_SetAttr function.obj : error LNK2001: unresolved external symbol __imp__PyStaticMethod_Type function.obj : error LNK2019: unresolved external symbol __imp__PyObject_GetItem referenced in function "public: static void __cdecl boost::python::objects::function::add_to_namespace(class boost::python::api::object const &,char const *,cl ass boost::python::api::object const &,char const *)" (?add_to_namespace at function@objects at python@boost@@SAXABVobject at api @34 at PBD01@Z) object_protocol.obj : error LNK2001: unresolved external symbol __imp__PyObject_GetItem function.obj : error LNK2001: unresolved external symbol __imp__PyClass_Type function.obj : error LNK2019: unresolved external symbol __imp__PyMethod_New referenced in function _function_descr_get function.obj : error LNK2019: unresolved external symbol __imp__PyString_InternFromString referenced in function _functi on_get_name function.obj : error LNK2001: unresolved external symbol __imp__PyCFunction_Type life_support.obj : error LNK2019: unresolved external symbol __imp__PyWeakref_NewRef referenced in function "struct _obj ect * __cdecl boost::python::objects::make_nurse_and_patient(struct _object *,struct _object *)" (?make_nurse_and_patien t at objects@python at boost@@YAPAU_object@@PAU4 at 0@Z) life_support.obj : error LNK2019: unresolved external symbol __imp___PyObject_New referenced in function "struct _object * __cdecl boost::python::objects::make_nurse_and_patient(struct _object *,struct _object *)" (?make_nurse_and_patient at o bjects at python@boost@@YAPAU_object@@PAU4 at 0@Z) errors.obj : error LNK2001: unresolved external symbol __imp__PyExc_ValueError errors.obj : error LNK2001: unresolved external symbol __imp__PyExc_IndexError errors.obj : error LNK2001: unresolved external symbol __imp__PyExc_OverflowError builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyExc_OverflowError errors.obj : error LNK2019: unresolved external symbol __imp__PyErr_NoMemory referenced in function __catch$?handle_exce ption_impl at python@boost@@YA_NV?$function0 at X@2@@Z$0 module.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4 referenced in function "struct _object * __ cdecl boost::python::detail::init_module(char const *,void (__cdecl*)(void))" (?init_module at detail@python at boost@@YAPAU_o bject@@PBDP6AXXZ at Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_FromEncodedObject referenced in function _encode_string_unaryfunc builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyBool_Type builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyFloat_Type builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyComplex_Type builtin_converters.obj : error LNK2001: unresolved external symbol __imp__PyUnicode_Type builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyLong_AsLongLong referenced in function "publ ic: static __int64 __cdecl boost::python::converter::`anonymous namespace'::long_long_rvalue_from_python::extract(struct _object *)" (?extract at long_long_rvalue_from_python@?A0xa22ba1ea at converter@python at boost@@SA_JPAU_object@@@Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyLong_AsUnsignedLongLong referenced in functi on "public: static unsigned __int64 __cdecl boost::python::converter::`anonymous namespace'::unsigned_long_long_rvalue_f rom_python::extract(struct _object *)" (?extract at unsigned_long_long_rvalue_from_python@?A0xa22ba1ea at converter@python at boo st@@SA_KPAU_object@@@Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyComplex_RealAsDouble referenced in function "public: static class std::complex __cdecl boost::python::converter::`anonymous namespace'::complex_rvalue_from_ python::extract(struct _object *)" (?extract at complex_rvalue_from_python@?A0xa22ba1ea at converter@python at boost@@SA?AV?$comp lex at N@std@@PAU_object@@@Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyComplex_ImagAsDouble referenced in function "public: static class std::complex __cdecl boost::python::converter::`anonymous namespace'::complex_rvalue_from_ python::extract(struct _object *)" (?extract at complex_rvalue_from_python@?A0xa22ba1ea at converter@python at boost@@SA?AV?$comp lex at N@std@@PAU_object@@@Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyUnicodeUCS2_AsWideChar referenced in functio n "public: static class std::basic_string,class std::allocator > __cde cl boost::python::converter::`anonymous namespace'::wstring_rvalue_from_python::extract(struct _object *)" (?extract at wst ring_rvalue_from_python@?A0xa22ba1ea at converter@python at boost@@SA?AV?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _ W at 2@@std@@PAU_object@@@Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyString_Size referenced in function "public: static class std::basic_string,class std::allocator > __cdecl boost::python::co nverter::`anonymous namespace'::string_rvalue_from_python::extract(struct _object *)" (?extract at string_rvalue_from_pytho n@?A0xa22ba1ea at converter@python at boost@@SA?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@PAU_object@@@Z) builtin_converters.obj : error LNK2019: unresolved external symbol __imp__PyLong_AsUnsignedLong referenced in function " public: static unsigned char __cdecl boost::python::converter::`anonymous namespace'::unsigned_int_rvalue_from_python::extract(struct _object *)" (?extract@?$unsigned_int_rvalue_from_python at E@?A0xa22ba1ea at converter@python at boo st@@SAEPAU_object@@@Z) iterator.obj : error LNK2001: unresolved external symbol __imp__PyExc_StopIteration stl_iterator.obj : error LNK2019: unresolved external symbol __imp__PyIter_Next referenced in function "public: void __t hiscall boost::python::objects::stl_input_iterator_impl::increment(void)" (?increment at stl_input_iterator_impl@objects at py thon at boost@@QAEXXZ) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PyObject_GetAttr referenced in function "class bo ost::python::api::object __cdecl boost::python::api::getattr(class boost::python::api::object const &,class boost::pytho n::api::object const &)" (?getattr at api@python at boost@@YA?AVobject at 123@ABV4123 at 0@Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PyErr_ExceptionMatches referenced in function "cl ass boost::python::api::object __cdecl boost::python::api::getattr(class boost::python::api::object const &,class boost: :python::api::object const &,class boost::python::api::object const &)" (?getattr at api@python at boost@@YA?AVobject at 123@ABV4 123 at 00@Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PyObject_SetItem referenced in function "void __c decl boost::python::api::setitem(class boost::python::api::object const &,class boost::python::api::object const &,class boost::python::api::object const &)" (?setitem at api@python at boost@@YAXABVobject at 123@00 at Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PyObject_DelItem referenced in function "void __c decl boost::python::api::delitem(class boost::python::api::object const &,class boost::python::api::object const &)" (?d elitem at api@python at boost@@YAXABVobject at 123@0 at Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PySequence_GetSlice referenced in function "struc t _object * __cdecl boost::python::api::`anonymous namespace'::apply_slice(struct _object *,struct _object *,struct _obj ect *)" (?apply_slice@?A0xb75a7c44 at api@python at boost@@YAPAU_object@@PAU5 at 00@Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp___PyEval_SliceIndex referenced in function "struct _object * __cdecl boost::python::api::`anonymous namespace'::apply_slice(struct _object *,struct _object *,struct _obje ct *)" (?apply_slice@?A0xb75a7c44 at api@python at boost@@YAPAU_object@@PAU5 at 00@Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PySequence_SetSlice referenced in function "int _ _cdecl boost::python::api::`anonymous namespace'::assign_slice(struct _object *,struct _object *,struct _object *,struct _object *)" (?assign_slice@?A0xb75a7c44 at api@python at boost@@YAHPAU_object@@000 at Z) object_protocol.obj : error LNK2019: unresolved external symbol __imp__PySequence_DelSlice referenced in function "int _ _cdecl boost::python::api::`anonymous namespace'::assign_slice(struct _object *,struct _object *,struct _object *,struct _object *)" (?assign_slice@?A0xb75a7c44 at api@python at boost@@YAHPAU_object@@000 at Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyObject_RichCompare referenced in function "cla ss boost::python::api::object __cdecl boost::python::api::operator>(class boost::python::api::object const &,class boost ::python::api::object const &)" (??Oapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Add referenced in function "class boost ::python::api::object __cdecl boost::python::api::operator+(class boost::python::api::object const &,class boost::python ::api::object const &)" (??Hapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Subtract referenced in function "class boost::python::api::object __cdecl boost::python::api::operator-(class boost::python::api::object const &,class boost::p ython::api::object const &)" (??Gapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Multiply referenced in function "class boost::python::api::object __cdecl boost::python::api::operator*(class boost::python::api::object const &,class boost::p ython::api::object const &)" (??Dapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Divide referenced in function "class bo ost::python::api::object __cdecl boost::python::api::operator/(class boost::python::api::object const &,class boost::pyt hon::api::object const &)" (??Kapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Remainder referenced in function "class boost::python::api::object __cdecl boost::python::api::operator%(class boost::python::api::object const &,class boost:: python::api::object const &)" (??Lapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Lshift referenced in function "class bo ost::python::api::object __cdecl boost::python::api::operator<<(class boost::python::api::object const &,class boost::py thon::api::object const &)" (??6api at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Rshift referenced in function "class bo ost::python::api::object __cdecl boost::python::api::operator>>(class boost::python::api::object const &,class boost::py thon::api::object const &)" (??5api at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_And referenced in function "class boost ::python::api::object __cdecl boost::python::api::operator&(class boost::python::api::object const &,class boost::python ::api::object const &)" (??Iapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Xor referenced in function "class boost ::python::api::object __cdecl boost::python::api::operator^(class boost::python::api::object const &,class boost::python ::api::object const &)" (??Tapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_Or referenced in function "class boost: :python::api::object __cdecl boost::python::api::operator|(class boost::python::api::object const &,class boost::python: :api::object const &)" (??Uapi at python@boost@@YA?AVobject at 012@ABV3012 at 0@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceAdd referenced in function "clas s boost::python::api::object & __cdecl boost::python::api::operator+=(class boost::python::api::object &,class boost::py thon::api::object const &)" (??Yapi at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceSubtract referenced in function "class boost::python::api::object & __cdecl boost::python::api::operator-=(class boost::python::api::object &,class boos t::python::api::object const &)" (??Zapi at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceMultiply referenced in function "class boost::python::api::object & __cdecl boost::python::api::operator*=(class boost::python::api::object &,class boos t::python::api::object const &)" (??Xapi at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceDivide referenced in function "c lass boost::python::api::object & __cdecl boost::python::api::operator/=(class boost::python::api::object &,class boost: :python::api::object const &)" (??_0api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceRemainder referenced in function "class boost::python::api::object & __cdecl boost::python::api::operator%=(class boost::python::api::object &,class boo st::python::api::object const &)" (??_1api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceLshift referenced in function "c lass boost::python::api::object & __cdecl boost::python::api::operator<<=(class boost::python::api::object &,class boost ::python::api::object const &)" (??_3api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceRshift referenced in function "c lass boost::python::api::object & __cdecl boost::python::api::operator>>=(class boost::python::api::object &,class boost ::python::api::object const &)" (??_2api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceAnd referenced in function "clas s boost::python::api::object & __cdecl boost::python::api::operator&=(class boost::python::api::object &,class boost::py thon::api::object const &)" (??_4api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceXor referenced in function "clas s boost::python::api::object & __cdecl boost::python::api::operator^=(class boost::python::api::object &,class boost::py thon::api::object const &)" (??_6api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) object_operators.obj : error LNK2019: unresolved external symbol __imp__PyNumber_InPlaceOr referenced in function "class boost::python::api::object & __cdecl boost::python::api::operator|=(class boost::python::api::object &,class boost::pyt hon::api::object const &)" (??_5api at python@boost@@YAAAVobject at 012@AAV3012 at ABV3012@@Z) wrapper.obj : error LNK2019: unresolved external symbol __imp__PyDict_GetItemString referenced in function "protected: c lass boost::python::override __thiscall boost::python::detail::wrapper_base::get_override(char const *,struct _typeobjec t *)const " (?get_override at wrapper_base@detail at python@boost@@IBE?AVoverride at 34@PBDPAU_typeobject@@@Z) wrapper.obj : error LNK2001: unresolved external symbol __imp__PyMethod_Type import.obj : error LNK2019: unresolved external symbol __imp__PyImport_ImportModule referenced in function "class boost: :python::api::object __cdecl boost::python::import(class boost::python::str)" (?import at python@boost@@YA?AVobject at api@12@ Vstr at 12@@Z) exec.obj : error LNK2019: unresolved external symbol __imp__PyRun_StringFlags referenced in function "class boost::pytho n::api::object __cdecl boost::python::eval(class boost::python::str,class boost::python::api::object,class boost::python ::api::object)" (?eval at python@boost@@YA?AVobject at api@12 at Vstr@12 at V3412@1 at Z) exec.obj : error LNK2019: unresolved external symbol __imp__PyEval_GetGlobals referenced in function "class boost::pytho n::api::object __cdecl boost::python::eval(class boost::python::str,class boost::python::api::object,class boost::python ::api::object)" (?eval at python@boost@@YA?AVobject at api@12 at Vstr@12 at V3412@1 at Z) exec.obj : error LNK2019: unresolved external symbol __imp__PyRun_FileExFlags referenced in function "class boost::pytho n::api::object __cdecl boost::python::exec_file(class boost::python::str,class boost::python::api::object,class boost::p ython::api::object)" (?exec_file at python@boost@@YA?AVobject at api@12 at Vstr@12 at V3412@1 at Z) exec.obj : error LNK2019: unresolved external symbol __imp__PyFile_AsFile referenced in function "class boost::python::a pi::object __cdecl boost::python::exec_file(class boost::python::str,class boost::python::api::object,class boost::pytho n::api::object)" (?exec_file at python@boost@@YA?AVobject at api@12 at Vstr@12 at V3412@1 at Z) exec.obj : error LNK2019: unresolved external symbol __imp__PyFile_FromString referenced in function "class boost::pytho n::api::object __cdecl boost::python::exec_file(class boost::python::str,class boost::python::api::object,class boost::p ython::api::object)" (?exec_file at python@boost@@YA?AVobject at api@12 at Vstr@12 at V3412@1 at Z) ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.dll : fatal error LNK 1120: 135 unresolved externals call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 >nul link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /subsystem:console /out:"..\..\..\..\bin.v2\libs\python\build\msvc -10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.dll" /IMPLIB:"..\..\..\..\bin.v2\libs\python\build\msvc-10.0\d ebug\threading-multi\boost_python-vc100-mt-gd-1_49.lib" /LIBPATH:"C:\Python27\libs" @"..\..\..\..\bin.v2\libs\python\b uild\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.dll.rsp" if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% ...failed msvc.link.dll ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_ 49.dll ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.lib ..\..\..\. .\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.pdb... ...removing ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.lib ...removing ..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\threading-multi\boost_python-vc100-mt-gd-1_49.pdb ...skipped hello_ext.pyd for lack of boost_python-vc100-mt-gd-1_49.lib... ...skipped hello_ext.lib for lack of boost_python-vc100-mt-gd-1_49.lib... ...skipped hello_ext.pdb for lack of boost_python-vc100-mt-gd-1_49.lib... ...skipped boost_python-vc100-mt-gd-1_49.dll for lack of boost_python-vc100-mt-gd-1_49.dll... ...skipped hello_ext.pyd for lack of hello_ext.pyd... ...skipped hello for lack of hell o_ext.pyd... ...failed updating 3 targets... ...skipped 7 targets... What am I doing wrong? What should I do to compile project successfully? Thanks in Advance Payaam Shivaa From darkant at gmail.com Tue Apr 3 17:01:33 2012 From: darkant at gmail.com (DarkAnt) Date: Tue, 3 Apr 2012 11:01:33 -0400 Subject: [C++-sig] Boost::Python to_python converter Message-ID: I'm having a conceptual issue with the way C++ interfaces with Python. I'm trying to convert a C++ object to a Python object, but my attempt causes the program to crash. I suspect I'm doing a lot of things wrong. Ultimately I'd like to be able to pass C++ objects to a python function that modifies their values. #include #include struct Unit { int health; std::string name; std::string type; std::pair coord; }; struct Unit_to_python { static PyObject* convert(Unit const& unit) { return boost::python::incref(boost::python::object(unit).ptr()); } }; BOOST_PYTHON_MODULE(game) { boost::python::class_("Unit") .def_readwrite("health", &Unit::health) .def_readwrite("name", &Unit::name) .def_readwrite("type", &Unit::type) .def_readwrite("coord", &Unit::coord) ; } int main(int argc, char** argv) { Py_Initialize(); boost::python::to_python_converter(); Unit unit1; unit1.health = 100; unit1.name = "Tank"; unit1.type = "Armor"; boost::python::object foo(unit1); // crash: stack overflow return 0; } From stefan at seefeld.name Tue Apr 3 17:20:52 2012 From: stefan at seefeld.name (Stefan Seefeld) Date: Tue, 03 Apr 2012 11:20:52 -0400 Subject: [C++-sig] Boost::Python to_python converter In-Reply-To: References: Message-ID: <4F7B1554.6020802@seefeld.name> DarkAnt, have you tried taking out the explicit to_python converter ? I don't think you need that, as the class_ will already implicitly provide that. Also, out of curiosity: I'm not sure the "coord" member conversion will work out-of-the-box, unless you also reflect std::pair to Python using class_<> or a converter. Stefan -- ...ich hab' noch einen Koffer in Berlin... From darkant at gmail.com Tue Apr 3 17:58:00 2012 From: darkant at gmail.com (DarkAnt) Date: Tue, 3 Apr 2012 11:58:00 -0400 Subject: [C++-sig] Boost::Python to_python converter In-Reply-To: <4F7B1554.6020802@seefeld.name> References: <4F7B1554.6020802@seefeld.name> Message-ID: I removed everything except int health and I still crash. If I do not have the explicit to_python converter I receive this error message: TypeError: No to_python (by-value) converter found for C++ type: Unit On Tue, Apr 3, 2012 at 11:20 AM, Stefan Seefeld wrote: > DarkAnt, > > have you tried taking out the explicit to_python converter ? I don't > think you need that, as the class_ will already implicitly provide > that. > Also, out of curiosity: I'm not sure the "coord" member conversion will > work out-of-the-box, unless you also reflect std::pair to > Python using class_<> or a converter. > > ? ?Stefan > > -- > > ? ? ?...ich hab' noch einen Koffer in Berlin... > From stefan at seefeld.name Tue Apr 3 18:01:33 2012 From: stefan at seefeld.name (Stefan Seefeld) Date: Tue, 03 Apr 2012 12:01:33 -0400 Subject: [C++-sig] Boost::Python to_python converter In-Reply-To: References: <4F7B1554.6020802@seefeld.name> Message-ID: <4F7B1EDD.4030104@seefeld.name> DarkAnt, the problem is that you don't initialize / import the newly defined module. The attached version works fine for me. Stefan -- ...ich hab' noch einen Koffer in Berlin... -------------- next part -------------- A non-text attachment was scrubbed... Name: bpl.cc Type: text/x-c++src Size: 740 bytes Desc: not available URL: From darkant at gmail.com Tue Apr 3 18:09:57 2012 From: darkant at gmail.com (DarkAnt) Date: Tue, 3 Apr 2012 12:09:57 -0400 Subject: [C++-sig] Boost::Python to_python converter In-Reply-To: <4F7B1EDD.4030104@seefeld.name> References: <4F7B1554.6020802@seefeld.name> <4F7B1EDD.4030104@seefeld.name> Message-ID: Thanks a bunch Stefan! On Tue, Apr 3, 2012 at 12:01 PM, Stefan Seefeld wrote: > DarkAnt, > > the problem is that you don't initialize / import the newly defined > module. The attached version works fine for me. > > ? ?Stefan > > -- > > ? ? ?...ich hab' noch einen Koffer in Berlin... > From adam.preble at gmail.com Tue Apr 3 22:44:44 2012 From: adam.preble at gmail.com (Adam Preble) Date: Tue, 3 Apr 2012 15:44:44 -0500 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: On Tue, Apr 3, 2012 at 4:12 AM, Payam Shiva wrote: > Hi, > > I have trouble compiling the simplest examples with Boost.Python. I > hope you could help me find out what I'm doing wrong. > I am using Microsoft Visual C++ 2010 on 64-bit Windows 7. I use 64-bit > version of Python 2.7.2 from Enthought Python Distribution 7.2-2. I > installed Boost as described in "Simplified Build From Source" section > of Boost getting started guide, i.e. going to Boost.Build directory > and typing: > bootstarp > .\b2 > > Boost compiled without errors (except for a warning about MPI). Then I > created user-config.jam in my home directory containing the following > lines: > using msvc : 10.0 ; > using python : 2.7 : C:\\Python 27 ; > > Then I tried compiling the tutorial example, but I got the following > messages (and no DLL): > Building Boost.Python can be a real adventure. From where I'm sitting right now, I wouldn't be able to tell you what is wrong because I'm no expert myself. I had recently done a debug build, and wrote down my steps, at home. However, I'm betting you don't really need to build. It looks to me like you're not as concerned with building the DLL as you with just using them. If that is the case, then maybe consider the pre-built libraries you could get here: http://www.boostpro.com/download/ That *should* just work, but you could smash into some odd compatibility stuff with however Enthought built their distribution--then you'd have to build from source. -------------- next part -------------- An HTML attachment was scrubbed... URL: From payaam.shivaa at gmail.com Wed Apr 4 06:36:15 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Wed, 4 Apr 2012 09:06:15 +0430 Subject: [C++-sig] Cplusplus-sig Digest, Vol 43, Issue 2 In-Reply-To: References: Message-ID: >It looks to me like you're not as concerned with building the DLL as you with just > using them. ?If that is the case, then maybe consider the pre-built > libraries you could get here: > > http://www.boostpro.com/download/ The problem is that my home computer, which I use for development, isn't connected to the internet. Downloading Boost sources from school and building them at home is the only way for me to install Boost, because BoostPro doesn't offer an offline installer. (Well, it does. But only for enterprise customers. That's not an option for me either) From adam.preble at gmail.com Wed Apr 4 15:22:42 2012 From: adam.preble at gmail.com (Adam Preble) Date: Wed, 4 Apr 2012 08:22:42 -0500 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: For what it's worth, here's what I have when I did a 32-bit debugging build of Stackless Python. Note that I have turned on debugging and stuff like that. You don't need that, but it should give you an idea: user-config.jam using python : 2.6 : D:\\temp\\stackless_src\\python-2.6.5-stackless\\PCbuild\\python_d.exe : D:\\Python26\\Include : D:\\temp\\stackless_src\\python-2.6.5-stackless\\PCbuild : on ; my build sequence (for doing the whole thing) set INCLUDE=D:\Python26\include;D:\Python26\include\Stackless b2 --toolset=msvc-10.0 --build-type=complete stage b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=32 stage b2 --toolset=msvc-10.0 --user-config=user-config.jam --with-python --build-type=complete architecture=x86 address-model=32 stage > Building Boost.Python can be a real adventure. From where I'm sitting > right now, I wouldn't be able to tell you what is wrong because I'm no > expert myself. I had recently done a debug build, and wrote down my steps, > at home. However, I'm betting you don't really need to build. It looks to > me like you're not as concerned with building the DLL as you with just > using them. If that is the case, then maybe consider the pre-built > libraries you could get here: > > http://www.boostpro.com/download/ > > That *should* just work, but you could smash into some odd compatibility > stuff with however Enthought built their distribution--then you'd have to > build from source. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From payaam.shivaa at gmail.com Fri Apr 6 07:12:28 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Fri, 6 Apr 2012 09:42:28 +0430 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: I downloaded the prebuilt binaries from here: http://boost.teeks99.com/ but I don't know how to use them. Right now, Boost source is decompressed in C:\Boost\boost_1_49_0 and the prebuilt binaries are in C:\Boost\lib32. I couldn't find anything in the jamfile about binaries. Can you help me configure them? Thanks From adam.preble at gmail.com Fri Apr 6 07:59:42 2012 From: adam.preble at gmail.com (Adam Preble) Date: Fri, 6 Apr 2012 00:59:42 -0500 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: Now that you have the binaries, you should be ready to use them. There should be no need to configure jam files. If you start pointing to those libraries in your Visual Studio project, they should link with your code. This assumes the binaries you're using mate up with how you'd building your Visual Studio project (32-bit, 64-bit, that stuff). On Fri, Apr 6, 2012 at 12:12 AM, Payam Shiva wrote: > I downloaded the prebuilt binaries from here: http://boost.teeks99.com/ > but I don't know how to use them. Right now, Boost source is > decompressed in C:\Boost\boost_1_49_0 and the prebuilt binaries are in > C:\Boost\lib32. I couldn't find anything in the jamfile about > binaries. Can you help me configure them? > > Thanks > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From payaam.shivaa at gmail.com Fri Apr 6 11:14:45 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Fri, 6 Apr 2012 13:44:45 +0430 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: I'm totally new to Boost.Python, so I'm trying to follow the tutorial. It says to cd to the tutorial folder and invoke bjam. When I do this, it still gives me the same error message. I tried using VS too. I did the following: 1. I created a new project (W32 Project and I chose DLL output) 2. I added C:\Boost\boost_1_49_0 and C:\Python27\include to C/C++ additional include directories in property manager 3. I added C:\Boost\lib32 and C:\Python27\libs to additional linker directories in property manager 4. I choose not to use precompiled headers 5. I delete the automatically created files, create a new C++ source file named hello.cpp and copy the contents of hello world example from the tutorial in it. 6. I build the project. It gives me the following message: 1>------ Build started: Project: BPTest, Configuration: Release Win32 ------ 1>Build started 4/6/2012 1:25:35 PM. 1>InitializeBuildStatus: 1> Touching "Release\BPTest.unsuccessfulbuild". 1>ClCompile: 1> hello.cpp 1>Link: 1> Creating library c:\users\payaam\documents\visual studio 2010\Projects\BPTest\Release\BPTest.lib and object c:\users\payaam\documents\visual studio 2010\Projects\BPTest\Release\BPTest.exp 1>hello.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct 1>hello.obj : error LNK2001: unresolved external symbol __imp__PyString_Type 1>c:\users\payaam\documents\visual studio 2010\Projects\BPTest\Release\BPTest.dll : fatal error LNK1120: 2 unresolved externals 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:10.12 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Please help me understand what to do to build this simple example, under VS or bjam. Thanks On 4/6/12, Adam Preble wrote: > Now that you have the binaries, you should be ready to use them. There > should be no need to configure jam files. If you start pointing to those > libraries in your Visual Studio project, they should link with your code. > This assumes the binaries you're using mate up with how you'd building > your Visual Studio project (32-bit, 64-bit, that stuff). > > On Fri, Apr 6, 2012 at 12:12 AM, Payam Shiva wrote: > >> I downloaded the prebuilt binaries from here: http://boost.teeks99.com/ >> but I don't know how to use them. Right now, Boost source is >> decompressed in C:\Boost\boost_1_49_0 and the prebuilt binaries are in >> C:\Boost\lib32. I couldn't find anything in the jamfile about >> binaries. Can you help me configure them? >> >> Thanks >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> http://mail.python.org/mailman/listinfo/cplusplus-sig >> > From wmamrak at gmail.com Fri Apr 6 12:02:47 2012 From: wmamrak at gmail.com (Wojciech Mamrak) Date: Fri, 6 Apr 2012 12:02:47 +0200 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: Hi, I am lost. Do you wan't to build boost::python libraries or an example using them? Bjam is used for the former only. regards W dniu 6 kwietnia 2012 11:14 u?ytkownik Payam Shiva napisa?: > I'm totally new to Boost.Python, so I'm trying to follow the tutorial. > It says to cd to the tutorial folder and invoke bjam. When I do this, > it still gives me the same error message. > > I tried using VS too. I did the following: > 1. I created a new project (W32 Project and I chose DLL output) > 2. I added C:\Boost\boost_1_49_0 and C:\Python27\include to C/C++ > additional include directories in property manager > 3. I added C:\Boost\lib32 and C:\Python27\libs to additional linker > directories in property manager > 4. I choose not to use precompiled headers > 5. I delete the automatically created files, create a new C++ source > file named hello.cpp and copy the contents of hello world example from > the tutorial in it. > 6. I build the project. It gives me the following message: > > 1>------ Build started: Project: BPTest, Configuration: Release Win32 ------ > 1>Build started 4/6/2012 1:25:35 PM. > 1>InitializeBuildStatus: > 1> ?Touching "Release\BPTest.unsuccessfulbuild". > 1>ClCompile: > 1> ?hello.cpp > 1>Link: > 1> ? ? Creating library c:\users\payaam\documents\visual studio > 2010\Projects\BPTest\Release\BPTest.lib and object > c:\users\payaam\documents\visual studio > 2010\Projects\BPTest\Release\BPTest.exp > 1>hello.obj : error LNK2001: unresolved external symbol __imp___Py_NoneStruct > 1>hello.obj : error LNK2001: unresolved external symbol __imp__PyString_Type > 1>c:\users\payaam\documents\visual studio > 2010\Projects\BPTest\Release\BPTest.dll : fatal error LNK1120: 2 > unresolved externals > 1> > 1>Build FAILED. > 1> > 1>Time Elapsed 00:00:10.12 > ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== > > > > Please help me understand what to do to build this simple example, > under VS or bjam. > > Thanks > > On 4/6/12, Adam Preble wrote: >> Now that you have the binaries, you should be ready to use them. ?There >> should be no need to configure jam files. ?If you start pointing to those >> libraries in your Visual Studio project, they should link with your code. >> ?This assumes the binaries you're using mate up with how you'd building >> your Visual Studio project (32-bit, 64-bit, that stuff). >> >> On Fri, Apr 6, 2012 at 12:12 AM, Payam Shiva wrote: >> >>> I downloaded the prebuilt binaries from here: http://boost.teeks99.com/ >>> but I don't know how to use them. Right now, Boost source is >>> decompressed in C:\Boost\boost_1_49_0 and the prebuilt binaries are in >>> C:\Boost\lib32. I couldn't find anything in the jamfile about >>> binaries. Can you help me configure them? >>> >>> Thanks >>> _______________________________________________ >>> Cplusplus-sig mailing list >>> Cplusplus-sig at python.org >>> http://mail.python.org/mailman/listinfo/cplusplus-sig >>> >> > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From payaam.shivaa at gmail.com Fri Apr 6 15:50:07 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Fri, 6 Apr 2012 18:20:07 +0430 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: What I am trying to do is the latter (using Boost.Python). Because I'm completely new to this, I am trying to follow the tutorial. Please take a look at this link: http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/hello.html If it's possible to write and build C++ parts in VS, I would definitely use it. The problem is I don't know how. I explained what happened when I tried building the example in the link above using both VS and bjam in my previous posts. If you know how I can setup build environment correctly, please help me. Thanks From adam.preble at gmail.com Fri Apr 6 16:02:44 2012 From: adam.preble at gmail.com (Adam Preble) Date: Fri, 6 Apr 2012 09:02:44 -0500 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: For my stuff, under Linker->Input, I explicitly listed my Boost.Python lib and the Python lib. Like so: libboost_python-vc100-mt-gy-1_47.lib python26_d.lib Actual names for yours will vary. By chance are you new to Visual Studio generally? On Fri, Apr 6, 2012 at 8:50 AM, Payam Shiva wrote: > What I am trying to do is the latter (using Boost.Python). Because I'm > completely new to this, I am trying to follow the tutorial. Please > take a look at this link: > > http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/hello.html > > If it's possible to write and build C++ parts in VS, I would > definitely use it. The problem is I don't know how. I explained what > happened when I tried building the example in the link above using > both VS and bjam in my previous posts. If you know how I can setup > build environment correctly, please help me. > > Thanks > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul at kroitor.ca Fri Apr 6 16:30:37 2012 From: paul at kroitor.ca (Paul Kroitor) Date: Fri, 6 Apr 2012 10:30:37 -0400 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: We had a similar problem last September. http://mail.python.org/pipermail/cplusplus-sig/2011-September/016142.htm l It's not clear to me if your issue is the same one, a related one, or simply similar. We created a ticket on the bugtracking system (https://svn.boost.org/trac/boost/ticket/5877 ) , but nothing seems to have come of it. In the meantime, we ignored the fact that the sample didn't compile, and just started using boost.python in VS2010, which worked out fine. Paul Kroitor From: cplusplus-sig-bounces+paul=kroitor.ca at python.org [mailto:cplusplus-sig-bounces+paul=kroitor.ca at python.org] On Behalf Of Adam Preble Sent: April-06-12 10:03 AM To: Development of Python/C++ integration Subject: Re: [C++-sig] Problem Compiling Boost.Python Example For my stuff, under Linker->Input, I explicitly listed my Boost.Python lib and the Python lib. Like so: libboost_python-vc100-mt-gy-1_47.lib python26_d.lib Actual names for yours will vary. By chance are you new to Visual Studio generally? On Fri, Apr 6, 2012 at 8:50 AM, Payam Shiva wrote: What I am trying to do is the latter (using Boost.Python). Because I'm completely new to this, I am trying to follow the tutorial. Please take a look at this link: http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/p ython/hello.html If it's possible to write and build C++ parts in VS, I would definitely use it. The problem is I don't know how. I explained what happened when I tried building the example in the link above using both VS and bjam in my previous posts. If you know how I can setup build environment correctly, please help me. Thanks _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig at python.org http://mail.python.org/mailman/listinfo/cplusplus-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.preble at gmail.com Fri Apr 6 17:02:22 2012 From: adam.preble at gmail.com (Adam Preble) Date: Fri, 6 Apr 2012 10:02:22 -0500 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: There's a good question: How could one contribute changes to the web documentation? There have been a few things in the past I feel would have been more widely understandable. For me, I remember getting debug symbols was an adventure. The documentation was technically all there, but it didn't make sense until I had already succeeded. A lot of documentation ends up being that way so I'm not too surprised, and for all it matters if I have an idea I figure somebody would take it. On Fri, Apr 6, 2012 at 9:30 AM, Paul Kroitor wrote: > We had a similar problem last September.**** > > ** ** > > http://mail.python.org/pipermail/cplusplus-sig/2011-September/016142.html* > *** > > ** ** > > It's not clear to me if your issue is the same one, a related one, or > simply similar.**** > > ** ** > > We created a ticket on the bugtracking system ( > https://svn.boost.org/trac/boost/ticket/5877) , but nothing seems to have > come of it. In the meantime, we ignored the fact that the sample didn't > compile, and just started using boost.python in VS2010, which worked out > fine.**** > > ** ** > > Paul Kroitor**** > > ** ** > > *From:* cplusplus-sig-bounces+paul=kroitor.ca at python.org [mailto: > cplusplus-sig-bounces+paul=kroitor.ca at python.org] *On Behalf Of *Adam > Preble > *Sent:* April-06-12 10:03 AM > *To:* Development of Python/C++ integration > *Subject:* Re: [C++-sig] Problem Compiling Boost.Python Example**** > > ** ** > > For my stuff, under Linker->Input, I explicitly listed my Boost.Python lib > and the Python lib. Like so:**** > > ** ** > > libboost_python-vc100-mt-gy-1_47.lib**** > > python26_d.lib**** > > ** ** > > Actual names for yours will vary. By chance are you new to Visual Studio > generally? **** > > ** ** > > On Fri, Apr 6, 2012 at 8:50 AM, Payam Shiva > wrote:**** > > What I am trying to do is the latter (using Boost.Python). Because I'm > completely new to this, I am trying to follow the tutorial. Please > take a look at this link: > > http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/hello.html > > If it's possible to write and build C++ parts in VS, I would > definitely use it. The problem is I don't know how. I explained what > happened when I tried building the example in the link above using > both VS and bjam in my previous posts. If you know how I can setup > build environment correctly, please help me.**** > > > Thanks > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig**** > > ** ** > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From payaam.shivaa at gmail.com Fri Apr 6 18:03:52 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Fri, 6 Apr 2012 20:33:52 +0430 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: Thank you Adam. I tried what you said, but it doesn't work for me. It gave an error, among a bunch of others, that it couldn't find python26.lib. I have Python 2.7 installed on my computer, so it makes sense. Maybe the person who compiled the libraries had Python 2.6 installed. Anyway, just out of curiosity, I changed the name of python27.lib in C:\Python27\libs to python26.lib and also changed it in in Linker->Input->Additional Dependencies. This time it said it couldn't find python27.lib. I don't understand. Does it expect python27.lib and python26.lib to be present at the same time. After four days and putting hours of work trying to figure out how this thing woks, I can't even compile a hello world example. I'm giving up. Thank you for being so helpful, but maybe Boost.Python just isn't for me. I might check it out again a couple of years later. I hope by that time, someone has created a simple way to install it, so everyone could start using it right away, just like Python itself. Thanks Goodbye From wmamrak at gmail.com Fri Apr 6 22:59:21 2012 From: wmamrak at gmail.com (Wojciech Mamrak) Date: Fri, 6 Apr 2012 22:59:21 +0200 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: Wait, don't give up :) Tomorrow I will send you a msvc solution of a simple application that embedds python, so that you can check the compilation, ok? W dniu 6 kwietnia 2012 18:03 u?ytkownik Payam Shiva napisa?: > Thank you Adam. I tried what you said, but it doesn't work for me. It > gave an error, among a bunch of others, that it couldn't find > python26.lib. I have Python 2.7 installed on my computer, so it makes > sense. Maybe the person who compiled the libraries had Python 2.6 > installed. > Anyway, just out of curiosity, I changed the name of python27.lib in > C:\Python27\libs to python26.lib and also changed it in in > Linker->Input->Additional Dependencies. This time it said it couldn't > find python27.lib. I don't understand. Does it expect python27.lib and > python26.lib to be present at the same time. > > After four days and putting hours of work trying to figure out how > this thing woks, I can't even compile a hello world example. I'm > giving up. Thank you for being so helpful, but maybe Boost.Python just > isn't for me. I might check it out again a couple of years later. I > hope by that time, someone has created a simple way to install it, so > everyone could start using it right away, just like Python itself. > > Thanks > Goodbye > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From payaam.shivaa at gmail.com Sat Apr 7 02:36:56 2012 From: payaam.shivaa at gmail.com (Payam Shiva) Date: Sat, 7 Apr 2012 05:06:56 +0430 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: Message-ID: 2012/4/7 Wojciech Mamrak : > Wait, don't give up :) > Tomorrow I will send you a msvc solution of a simple application that > embedds python, so that you can check the compilation, ok? Thank you. I'll be waiting. From s_sourceforge at nedprod.com Sat Apr 7 14:29:48 2012 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Sat, 07 Apr 2012 13:29:48 +0100 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: References: , , Message-ID: <4F80333C.11686.65518927@s_sourceforge.nedprod.com> On 6 Apr 2012 at 20:33, Payam Shiva wrote: > Thank you Adam. I tried what you said, but it doesn't work for me. It > gave an error, among a bunch of others, that it couldn't find > python26.lib. I have Python 2.7 installed on my computer, so it makes > sense. Maybe the person who compiled the libraries had Python 2.6 > installed. That looks extremely likely. > Anyway, just out of curiosity, I changed the name of python27.lib in > C:\Python27\libs to python26.lib and also changed it in in > Linker->Input->Additional Dependencies. This time it said it couldn't > find python27.lib. I don't understand. Does it expect python27.lib and > python26.lib to be present at the same time. PE stub linker files (the .libs) are tied to their DLL. Even if you rename them it knows what they really are. > After four days and putting hours of work trying to figure out how > this thing woks, I can't even compile a hello world example. I'm > giving up. Thank you for being so helpful, but maybe Boost.Python just > isn't for me. I might check it out again a couple of years later. I > hope by that time, someone has created a simple way to install it, so > everyone could start using it right away, just like Python itself. With respect, if you're struggling with getting MSVC working then probably starting with Boost is ambitious. Generally speaking, the documentation for Boost assumes a certain minimum understanding, and I've always found that level of understanding is considerably higher than the average C++ programmer. I struggled throughout my time with Boost, and I had previously written my own metaprogramming library. Hence if you're struggling now, you are likely to be struggling for the foreseeable future. That said, investing a full-time equivalent year of your life mastering Boost will improve you as a person. I'm not joking - expect your higher order logic skills to improve immensely, and if you can find an employer capable of recognising that skill expect a highly rewarded career. But it does take at least 2500 hours. Very few programmers can do it in less. It's still worth doing though, and it'll stand to you for the rest of your life. I'd urge you to stick with it. Start with figuring out how to build Boost using a non-bjam build system (and NOT using Visual Studio). I personally like scons as it's really python, even though it can't scale. Niall -- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ From wmamrak at gmail.com Sat Apr 7 15:31:29 2012 From: wmamrak at gmail.com (Wojciech Mamrak) Date: Sat, 7 Apr 2012 15:31:29 +0200 Subject: [C++-sig] Problem Compiling Boost.Python Example In-Reply-To: <4F80333C.11686.65518927@s_sourceforge.nedprod.com> References: <4F80333C.11686.65518927@s_sourceforge.nedprod.com> Message-ID: Exemplary project sent. W dniu 7 kwietnia 2012 14:29 u?ytkownik Niall Douglas napisa?: > On 6 Apr 2012 at 20:33, Payam Shiva wrote: > >> Thank you Adam. I tried what you said, but it doesn't work for me. It >> gave an error, among a bunch of others, that it couldn't find >> python26.lib. I have Python 2.7 installed on my computer, so it makes >> sense. Maybe the person who compiled the libraries had Python 2.6 >> installed. > > That looks extremely likely. > >> Anyway, just out of curiosity, I changed the name of python27.lib in >> C:\Python27\libs to python26.lib and also changed it in in >> Linker->Input->Additional Dependencies. This time it said it couldn't >> find python27.lib. I don't understand. Does it expect python27.lib and >> python26.lib to be present at the same time. > > PE stub linker files (the .libs) are tied to their DLL. Even if you > rename them it knows what they really are. > >> After four days and putting hours of work trying to figure out how >> this thing woks, I can't even compile a hello world example. I'm >> giving up. Thank you for being so helpful, but maybe Boost.Python just >> isn't for me. I might check it out again a couple of years later. I >> hope by that time, someone has created a simple way to install it, so >> everyone could start using it right away, just like Python itself. > > With respect, if you're struggling with getting MSVC working then > probably starting with Boost is ambitious. > > Generally speaking, the documentation for Boost assumes a certain > minimum understanding, and I've always found that level of > understanding is considerably higher than the average C++ programmer. > I struggled throughout my time with Boost, and I had previously > written my own metaprogramming library. > > Hence if you're struggling now, you are likely to be struggling for > the foreseeable future. That said, investing a full-time equivalent > year of your life mastering Boost will improve you as a person. I'm > not joking - expect your higher order logic skills to improve > immensely, and if you can find an employer capable of recognising > that skill expect a highly rewarded career. > > But it does take at least 2500 hours. Very few programmers can do it > in less. It's still worth doing though, and it'll stand to you for > the rest of your life. I'd urge you to stick with it. Start with > figuring out how to build Boost using a non-bjam build system (and > NOT using Visual Studio). I personally like scons as it's really > python, even though it can't scale. > > Niall > > -- > Technology & Consulting Services - ned Productions Limited. > http://www.nedproductions.biz/. VAT reg: IE 9708311Q. > Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ > > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From brandsmeier at gmx.de Tue Apr 10 12:58:03 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Tue, 10 Apr 2012 12:58:03 +0200 Subject: [C++-sig] std::complex vs python complex Message-ID: Dear list, I exported a wrapper for std::complex to python and I am willing to always use this class in python and I never want to use pythons own `complex` data type. However, a funny thing happens when I export the addition operator (the implemenation is given in the STL ...) .def(self + self) Now I get that: type(scalar_cd(1,2) + scalar_cd(1,2)) But my own type is of the form: type(scalar_cd(1,2)) Why did this happen and how can I avoid this? Later own I get problems when I want to pass this back to C++. I remember that pythons own complex type is a bit special and does not cooperate nicely with boost::python and std::complex<> but how did python/boost::python end up converting the result of the addition to `complex`? I am using: Python 2.7.2 boost-1.46.1 Best regards, Holger Brandsmeier From talljimbo at gmail.com Tue Apr 10 17:37:55 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Tue, 10 Apr 2012 11:37:55 -0400 Subject: [C++-sig] std::complex vs python complex In-Reply-To: References: Message-ID: <4F8453D3.4010909@gmail.com> On 04/10/2012 06:58 AM, Holger Brandsmeier wrote: > Dear list, > > I exported a wrapper for std::complex to python and I am > willing to always use this class in python and I never want to use > pythons own `complex` data type. > > However, a funny thing happens when I export the addition operator > (the implemenation is given in the STL ...) > .def(self + self) > > Now I get that: > type(scalar_cd(1,2) + scalar_cd(1,2)) > > > But my own type is of the form: > type(scalar_cd(1,2)) > > > > Why did this happen and how can I avoid this? Later own I get problems > when I want to pass this back to C++. > > I remember that pythons own complex type is a bit special and does not > cooperate nicely with boost::python and std::complex<> but how did > python/boost::python end up converting the result of the addition to > `complex`? > > I am using: > Python 2.7.2 > boost-1.46.1 > Does your custom complex type provide implicit conversion to std::complex? If so, I'm guessing there's something going wrong with overload resolution; Boost.Python's operator wrappers simply invoke the C++ operators and lookup the Python conversion based on the result type. You can test this yourself with something like this: -------------------------------------------------------------------- // use any namespace other than the one your classes are defined in namespace { template void test_expr(T const & x) { std::cerr << typeid(x).name() << std::endl; } } // int main() { test_expr(whatever::scalar_cd(1,2) + whatever::scalar_cd(1,2)); return 0; } -------------------------------------------------------------------- If the output you see when running the above is std::complex, you'll have a test case that doesn't involve Boost.Python you can use to debug your overload resolution. If not, let me know, and I'll dig deeper into what Boost.Python's doing. HTH! Jim From brandsmeier at gmx.de Thu Apr 12 18:48:36 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Thu, 12 Apr 2012 18:48:36 +0200 Subject: [C++-sig] overloaded functions and order of arguments Message-ID: Dear list, I exported the C++ function `sin` both for real and complex numbers (`float` and `complex` in python / `double` and `std::complex` in C++) and I noticed that calling `sin(2.3)` gives `(0.7457052121767203-0j)` so a complex number. Why is that? In which order does boost python handle overloading of functions anyways? More precisely I exported this function to python >>> sin? Type: function Base Class: String Form: Namespace: Interactive Docstring: sin( (float)arg1) -> float : C++ signature : double sin(double) sin( (complex)arg1) -> complex : C++ signature : std::complex sin(std::complex) Notice in particular that the `float` version is above the `complex` version, so if boost::python things this is ambiguous (I don't condider this abiguous), but even if so I was kind of expecting him to use the first exported function, not the second. Any ideas? -Holger From brandsmeier at gmx.de Thu Apr 12 18:57:12 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Thu, 12 Apr 2012 18:57:12 +0200 Subject: [C++-sig] std::complex vs python complex In-Reply-To: <4F8453D3.4010909@gmail.com> References: <4F8453D3.4010909@gmail.com> Message-ID: Jim, I didn't implement my own `version of std::complex` I just exported `std::complex` as my own class. I only later found out that this type is already exported by boost::python itself. I just stopped exporting `std::complex` by myself which mostly works. I am not fully happy with the situation as I also export `std::complex` and `std::complex` which are complex variables build upon 128bit and 256bit doubles. For consistency I would like to treat complex numbers with 64bit, 128bit and 256bit doubles all the same and to completely ignore python's own `complex` type. That way I avoid problems where parts of the code work for 64bit complex numbers but fail to work once I switch to 128bit. It is probably difficult to stop boost::python from its special treatment of `std::complex` and how it ties this to python's `complex`, so I will have to live with the current situation. -Holger On Tue, Apr 10, 2012 at 17:37, Jim Bosch wrote: > On 04/10/2012 06:58 AM, Holger Brandsmeier wrote: >> >> Dear list, >> >> I exported a wrapper for std::complex ?to python and I am >> willing to always use this class in python and I never want to use >> pythons own `complex` data type. >> >> However, a funny thing happens when I export the addition operator >> (the implemenation is given in the STL ...) >> ? ? ? ? .def(self + self) >> >> Now I get that: >> type(scalar_cd(1,2) + scalar_cd(1,2)) >> >> >> But my own type is of the form: >> type(scalar_cd(1,2)) >> >> >> >> Why did this happen and how can I avoid this? Later own I get problems >> when I want to pass this back to C++. >> >> I remember that pythons own complex type is a bit special and does not >> cooperate nicely with boost::python and std::complex<> ?but how did >> python/boost::python end up converting the result of the addition to >> `complex`? >> >> I am using: >> Python 2.7.2 >> boost-1.46.1 >> > > Does your custom complex type provide implicit conversion to std::complex? > > If so, I'm guessing there's something going wrong with overload resolution; > Boost.Python's operator wrappers simply invoke the C++ operators and lookup > the Python conversion based on the result type. You can test this yourself > with something like this: > > -------------------------------------------------------------------- > > // use any namespace other than the one your classes are defined in > namespace { > > template void test_expr(T const & x) { > ? ?std::cerr << typeid(x).name() << std::endl; > } > > } // > > int main() { > ? ?test_expr(whatever::scalar_cd(1,2) + whatever::scalar_cd(1,2)); > ? ?return 0; > } > > -------------------------------------------------------------------- > > If the output you see when running the above is std::complex, you'll have a > test case that doesn't involve Boost.Python you can use to debug your > overload resolution. ?If not, let me know, and I'll dig deeper into what > Boost.Python's doing. > > HTH! > > Jim > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From rwgrosse-kunstleve at lbl.gov Thu Apr 12 19:03:20 2012 From: rwgrosse-kunstleve at lbl.gov (Ralf Grosse-Kunstleve) Date: Thu, 12 Apr 2012 10:03:20 -0700 Subject: [C++-sig] overloaded functions and order of arguments In-Reply-To: References: Message-ID: Did you already try .def'ing the functions with the order reversed? I think it should work for your case. Boost.Python uses a simple "first match" approach, I think trying bottom up for functions and member functions, top down for constructors (for weird reasons). On Thu, Apr 12, 2012 at 9:48 AM, Holger Brandsmeier wrote: > Dear list, > > I exported the C++ function `sin` both for real and complex numbers > (`float` and `complex` in python / `double` and `std::complex` in C++) > and I noticed that calling `sin(2.3)` gives `(0.7457052121767203-0j)` > so a complex number. Why is that? In which order does boost python > handle overloading of functions anyways? > > > More precisely I exported this function to python > > >>> sin? > Type: function > Base Class: > String Form: > Namespace: Interactive > Docstring: > sin( (float)arg1) -> float : > > C++ signature : > double sin(double) > > sin( (complex)arg1) -> complex : > > C++ signature : > std::complex sin(std::complex) > > Notice in particular that the `float` version is above the `complex` > version, so if boost::python things this is ambiguous (I don't > condider this abiguous), but even if so I was kind of expecting him to > use the first exported function, not the second. > > Any ideas? > -Holger > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brandsmeier at gmx.de Thu Apr 12 21:01:47 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Thu, 12 Apr 2012 21:01:47 +0200 Subject: [C++-sig] overloaded functions and order of arguments In-Reply-To: References: Message-ID: Indeed, reversing the order works. Thanks also for the explanation. This required to change my template metaprogramming code which I use to export the classes. This is not optimal as I want to know that no compiler errors occur for `double` before I get potentially more complicated compiler errors for `std::complex`, but I will probably have to live with that. -Holger On Thu, Apr 12, 2012 at 19:03, Ralf Grosse-Kunstleve wrote: > Did you already try .def'ing the functions with the order reversed? I think > it should work for your case. > Boost.Python uses a simple "first match" approach, I think trying bottom up > for functions and member functions, top down for constructors (for weird > reasons). > > On Thu, Apr 12, 2012 at 9:48 AM, Holger Brandsmeier > wrote: >> >> Dear list, >> >> I exported the C++ function `sin` both for real and complex numbers >> (`float` and `complex` in python / `double` and `std::complex` in C++) >> and I noticed that calling `sin(2.3)` gives `(0.7457052121767203-0j)` >> so a complex number. Why is that? In which order does boost python >> handle overloading of functions anyways? >> >> >> More precisely I exported this function to python >> >> >>> sin? >> Type: ? ? ? ? ? function >> Base Class: ? ? >> String Form: ? ? >> Namespace: ? ? ?Interactive >> Docstring: >> ? ?sin( (float)arg1) -> float : >> >> ? ? ? ?C++ signature : >> ? ? ? ? ? ?double sin(double) >> >> ? ?sin( (complex)arg1) -> complex : >> >> ? ? ? ?C++ signature : >> ? ? ? ? ? ?std::complex sin(std::complex) >> >> Notice in particular that the `float` version is above the `complex` >> version, so if boost::python things this is ambiguous (I don't >> condider this abiguous), but even if so I was kind of expecting him to >> use the first exported function, not the second. >> >> Any ideas? >> -Holger >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> http://mail.python.org/mailman/listinfo/cplusplus-sig > > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From j.reid at mail.cryst.bbk.ac.uk Fri Apr 13 16:16:07 2012 From: j.reid at mail.cryst.bbk.ac.uk (John Reid) Date: Fri, 13 Apr 2012 15:16:07 +0100 Subject: [C++-sig] Define class in 2 scopes without re-exposing Message-ID: Hi, If I want to define the same class (Inner) in 2 different scopes (Outer1 and Outer 2), I can do it like this: #include struct Outer1 {}; struct Outer2 {}; struct Inner {}; BOOST_PYTHON_MODULE( _sandbox ) { namespace bp = ::boost::python; { bp::scope scope = bp::class_< Outer1 >( "Outer1" ); bp::class_< Inner >( "Inner" ); } { bp::scope scope = bp::class_< Outer2 >( "Outer2" ); bp::class_< Inner >( "Inner" ); } } Unfortunately when I import the _sandbox module I get the standard error: RuntimeWarning: to-Python converter for Inner already registered; second conversion method ignored. and in debug build the second Inner registration asserts. Is there any way to test if Inner is already registered and if so just place it in the correct scope? Perhaps replacing the second scoped block with something like this: { bp::object class_Outer2 = bp::class_< Outer2 >( "Outer2" ); bp::type_info info = boost::python::type_id< Inner >(); const bp::converter::registration * reg = bp::converter::registry::query( info ); if( NULL == reg ) { bp::class_< Inner >( "Inner" ); } else { // Some magic here! } } Also I should say that the 2 scoped blocks of code aren't adjacent in my library so I don't really want to pass objects between them. I'm hoping for a solution that just extracts info from the boost.python registry. Thanks for any help, John. From dave at boostpro.com Sun Apr 15 04:23:06 2012 From: dave at boostpro.com (Dave Abrahams) Date: Sat, 14 Apr 2012 22:23:06 -0400 Subject: [C++-sig] Define class in 2 scopes without re-exposing References: Message-ID: on Fri Apr 13 2012, John Reid wrote: > Hi, > > If I want to define the same class (Inner) in 2 different scopes > (Outer1 and Outer 2), I can do it like this: > > #include > > struct Outer1 {}; > struct Outer2 {}; > struct Inner {}; > > BOOST_PYTHON_MODULE( _sandbox ) > { > namespace bp = ::boost::python; > { > bp::scope scope = bp::class_< Outer1 >( "Outer1" ); > bp::class_< Inner >( "Inner" ); > } > > { > bp::scope scope = bp::class_< Outer2 >( "Outer2" ); > bp::class_< Inner >( "Inner" ); > } > } > > Unfortunately when I import the _sandbox module I get the standard error: > > RuntimeWarning: to-Python converter for Inner already registered; > second conversion method ignored. > > and in debug build the second Inner registration asserts. You can't do this; don't even try. Each C++ class has to have a unique Python identity. If you just want to refer to the same class by a different name, you can of course: BOOST_PYTHON_MODULE( _sandbox ) { namespace bp = ::boost::python; object inner; { bp::scope scope = bp::class_< Outer1 >( "Outer1" ); inner = bp::class_< Inner >( "Inner" ); } { object outer2 = bp::class_< Outer2 >( "Outer2" ); outer2.attr("Inner") = inner; } } > Is there any way to test if Inner is already registered and if so just > place it in the correct scope? Perhaps replacing the second scoped > block with something like this: > > { > bp::object class_Outer2 = bp::class_< Outer2 >( "Outer2" ); > bp::type_info info = boost::python::type_id< Inner >(); > const bp::converter::registration * reg = > bp::converter::registry::query( info ); > if( NULL == reg ) { > bp::class_< Inner >( "Inner" ); > } else { > // Some magic here! > } > } > > Also I should say that the 2 scoped blocks of code aren't adjacent in > my library so I don't really want to pass objects between them. I'm > hoping for a solution that just extracts info from the boost.python > registry. BOOST_PYTHON_MODULE( _sandbox ) { namespace bp = ::boost::python; { bp::scope scope = bp::class_< Outer1 >( "Outer1" ); bp::class_< Inner >( "Inner" ); } { object outer2 = bp::class_< Outer2 >( "Outer2" ); outer2.attr("Inner") = scope().attr("Outer1").attr("Inner"); } } HTH-ly y'rs, -- Dave Abrahams BoostPro Computing http://www.boostpro.com From j.reid at mail.cryst.bbk.ac.uk Mon Apr 16 09:15:01 2012 From: j.reid at mail.cryst.bbk.ac.uk (John Reid) Date: Mon, 16 Apr 2012 08:15:01 +0100 Subject: [C++-sig] Define class in 2 scopes without re-exposing In-Reply-To: References: Message-ID: On 15/04/12 03:23, Dave Abrahams wrote: > > You can't do this; don't even try. Each C++ class has to have a unique > Python identity. If you just want to refer to the same class by a > different name, you can of course: > > BOOST_PYTHON_MODULE( _sandbox ) > { > namespace bp = ::boost::python; > object inner; > { > bp::scope scope = bp::class_< Outer1>( "Outer1" ); > inner = bp::class_< Inner>( "Inner" ); > } > > { > object outer2 = bp::class_< Outer2>( "Outer2" ); > outer2.attr("Inner") = inner; > } > } > I didn't know you could do that and it is useful but it is not quite what I had in mind. I would rather not pass the inner object around all the parts of my code that might need it. Is it possible to get it out of the registry in the second block? I'm guessing it must be in there somewhere as I get exactly the same behaviour (plus the warning message) if I just register the class in both blocks. Thanks, John. From talljimbo at gmail.com Mon Apr 16 17:32:00 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Mon, 16 Apr 2012 11:32:00 -0400 Subject: [C++-sig] Define class in 2 scopes without re-exposing In-Reply-To: References: Message-ID: <4F8C3B70.2020004@gmail.com> On 04/16/2012 03:15 AM, John Reid wrote: > > > On 15/04/12 03:23, Dave Abrahams wrote: >> >> You can't do this; don't even try. Each C++ class has to have a unique >> Python identity. If you just want to refer to the same class by a >> different name, you can of course: >> >> BOOST_PYTHON_MODULE( _sandbox ) >> { >> namespace bp = ::boost::python; >> object inner; >> { >> bp::scope scope = bp::class_< Outer1>( "Outer1" ); >> inner = bp::class_< Inner>( "Inner" ); >> } >> >> { >> object outer2 = bp::class_< Outer2>( "Outer2" ); >> outer2.attr("Inner") = inner; >> } >> } >> > > I didn't know you could do that and it is useful but it is not quite > what I had in mind. I would rather not pass the inner object around all > the parts of my code that might need it. Is it possible to get it out of > the registry in the second block? I'm guessing it must be in there > somewhere as I get exactly the same behaviour (plus the warning message) > if I just register the class in both blocks. > You can get it from the registry (see below), but it requires relying on what I'd consider implementation details of the library. If you can, I'd recommend just importing the module that contains outer1 and doing the above trick with that: bp::object mod1 = bp::import("module1"); bp::object outer2 = bp::class_< Outer2 >("Outer2"); outer2.attr("Inner") = mod1.attr("Outer1").attr("Inner"); If you do really want to use the registry, I think you want something like this: bp::converter::registration const * reg = bp::converter::registry::query(bp::type_id()); assert(reg); // 0 if you haven't wrapped Inner yet bp::object inner(bp::handle<>(bp::borrowed( reinterpret_cast(reg.get_class_object()) ))); Jim From dave at boostpro.com Mon Apr 16 20:13:18 2012 From: dave at boostpro.com (Dave Abrahams) Date: Mon, 16 Apr 2012 14:13:18 -0400 Subject: [C++-sig] Define class in 2 scopes without re-exposing References: Message-ID: on Mon Apr 16 2012, John Reid wrote: > On 15/04/12 03:23, Dave Abrahams wrote: >> >> You can't do this; don't even try. Each C++ class has to have a unique >> Python identity. If you just want to refer to the same class by a >> different name, you can of course: >> > >> BOOST_PYTHON_MODULE( _sandbox ) >> { >> namespace bp = ::boost::python; >> object inner; >> { >> bp::scope scope = bp::class_< Outer1>( "Outer1" ); >> inner = bp::class_< Inner>( "Inner" ); >> } >> >> { >> object outer2 = bp::class_< Outer2>( "Outer2" ); >> outer2.attr("Inner") = inner; >> } >> } >> > > I didn't know you could do that and it is useful but it is not quite > what I had in mind. I would rather not pass the inner object around > all the parts of my code that might need it. Is it possible to get it > out of the registry in the second block? Why don't you read to the end of my posting? The answer's there at the bottom :-) -- Dave Abrahams BoostPro Computing http://www.boostpro.com From j.reid at mail.cryst.bbk.ac.uk Mon Apr 16 21:34:29 2012 From: j.reid at mail.cryst.bbk.ac.uk (John Reid) Date: Mon, 16 Apr 2012 20:34:29 +0100 Subject: [C++-sig] Define class in 2 scopes without re-exposing In-Reply-To: References: Message-ID: On 16/04/12 19:13, Dave Abrahams wrote: > > on Mon Apr 16 2012, John Reid wrote: > >> On 15/04/12 03:23, Dave Abrahams wrote: >>> >>> You can't do this; don't even try. Each C++ class has to have a unique >>> Python identity. If you just want to refer to the same class by a >>> different name, you can of course: >>> >> >>> BOOST_PYTHON_MODULE( _sandbox ) >>> { >>> namespace bp = ::boost::python; >>> object inner; >>> { >>> bp::scope scope = bp::class_< Outer1>( "Outer1" ); >>> inner = bp::class_< Inner>( "Inner" ); >>> } >>> >>> { >>> object outer2 = bp::class_< Outer2>( "Outer2" ); >>> outer2.attr("Inner") = inner; >>> } >>> } >>> >> >> I didn't know you could do that and it is useful but it is not quite >> what I had in mind. I would rather not pass the inner object around >> all the parts of my code that might need it. Is it possible to get it >> out of the registry in the second block? > > Why don't you read to the end of my posting? The answer's there at the > bottom :-) > Thanks! I was guilty of reading your post too quickly. And thx to Jim too for what looks like a similar method. John. From adam.preble at gmail.com Tue Apr 17 08:00:32 2012 From: adam.preble at gmail.com (Adam Preble) Date: Tue, 17 Apr 2012 01:00:32 -0500 Subject: [C++-sig] Assign ownership of Python-constructed object to C++ runtime Message-ID: I am pondering trying to eliminate some usages of shared pointers in my code since I have finally completed enough of it that I have good ownership rules for things in place. I still have one spot, which is basically the main door to the C++ runtime, where I have a problem. I've been creating instances of some objects in Python, with the purpose of assigning to another object for safekeeping. Really that other object is what I have in mind for managing everything about these objects--including their runtimes. But I see the objects get destroyed when the Python declaration for them go out of scope. That would normally be the right thing. I'm trying to think of alternatives. The best I can think of is to use a static factory method instead that returns an internal reference. I'm intend to experiment with that now but I am wondering if there are some other things to consider instead. Inevitably somebody will ask why I'm doing away with the shared pointers. I have some cycles due to communication that means a lot of stuff never actually gets deleted due to the reference-counting methodology in them. When I used weak references, I found they were getting deleted too eagerly. And by this point, I otherwise have gotten an ownership hierarchy down. -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at crupp.de Wed Apr 18 19:57:14 2012 From: chris at crupp.de (Christoph Rupp) Date: Wed, 18 Apr 2012 19:57:14 +0200 Subject: [C++-sig] boost::python: marshalling buffers Message-ID: Hi, i have a C++ class that i'm wrapping with boost::python: class Foo { // ... const char *get_buffer(); size_t get_size() const; // ... }; I want to send this class through a thrift interface (which uses the write() method to send the data to a file or a socket). For a few days now i'm trying to implement this. By now i understand that i have to implement the buffer protocol, and i know that i can create a buffer with boost::python (read-only access is sufficient): inline object as_buffer(const Foo &f) { return object (handle<> (PyBuffer_FromMemory ((void*)f.get_buffer(), f.get_size()))); } (This is based on an email from 2009 that i found in this mailing list's archive.) But i do not know how to glue it together to form a full module. This is how the module looks right now: BOOST_PYTHON_MODULE(Foo) { class_("Foo", init()) .def("add", afn) .def("finalize", &Foo::finalize) .def("empty", &Foo::empty) .def("clear", &Foo::clear) ; } How can i include that buffer conversion? Thanks a lot, Christoph -------------- next part -------------- An HTML attachment was scrubbed... URL: From jjchristophe at yahoo.fr Thu Apr 19 00:55:02 2012 From: jjchristophe at yahoo.fr (christophe jean-joseph) Date: Wed, 18 Apr 2012 23:55:02 +0100 (BST) Subject: [C++-sig] Re : boost::python: C++/Python function overload issue In-Reply-To: References: Message-ID: <1334789702.12186.YahooMailNeo@web132302.mail.ird.yahoo.com> Hi, here is my problem. Let say have a C++ A class and a Ader class in Python, derived from A (through boost::python). I have a list of functions f_i in Ader overloading the equivalent functions with same name in A. The main is written in Python and call a method g of a C++ class B passing and argument of type Ader (it's written as A type under C++, but I don't have any type issue there). Let say B::g call a function f_1, calling f_2, calling f_3. The error occur at f_3 as I could identify it uses A::f_3 instead of Ader::f_3. By going down, I could confirm that, from f_1 to f_3, all the 3 called functions are the A version.? So my question is, how can I fix this issue so that the B::g function uses Ader functions (meanning Python functions) and not A functions? On a side, this is a C++/Python version of a code working fine when fully written in C++. Christophe Jean-Joseph -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsperf.unkn0wn at gmail.com Thu Apr 19 01:09:53 2012 From: jsperf.unkn0wn at gmail.com (JS Unkn0wn) Date: Thu, 19 Apr 2012 00:09:53 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues Message-ID: -:Background:- I am working on a cross platform project (Win32 with proprietary graphics lib, and a proprietary embedded device running a custom OS with custom compilers) -:Goals:- Using Boost.Python on both platforms (without dlls, as we will have to embed Python anyway). -:Problems:- Receiving <> in /MT, which is concerning to me since compiling as a DLL works but I must be able to deploy this on a system that has no DLL system. -:Setup steps taken so far (in order), and system config:- 1 - Windows XP Pro + SP3 2 - Visual Studio 2008 Standard + Service Pack (C++ and C# installed) 3 - Python 2.7 installed 4 - Boost Pro 1.47 installer for Windows installed (c:\boost_1_47) 5 - Boost 1.47 copied to (c:\boost_1_47_0) 6 - Boost Build 1.47 downloaded ... I've written a much more detailed log here ( http://jsperfunkn0wn.blogspot.co.uk/2012/04/installing-boostpython-python-27-for.html ). Here is the code I am trying to compile: http://pastebin.com/Rg2AeTms Regards, JSPerf Unkn0wn -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsperf.unkn0wn at gmail.com Thu Apr 19 01:21:57 2012 From: jsperf.unkn0wn at gmail.com (JS Unkn0wn) Date: Thu, 19 Apr 2012 00:21:57 +0100 Subject: [C++-sig] Re : boost::python: C++/Python function overload issue In-Reply-To: <1334789702.12186.YahooMailNeo@web132302.mail.ird.yahoo.com> References: <1334789702.12186.YahooMailNeo@web132302.mail.ird.yahoo.com> Message-ID: Does this ( http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/exposing.html ) answer your question? specifically "Class Virtual Functions". On Wed, Apr 18, 2012 at 11:55 PM, christophe jean-joseph < jjchristophe at yahoo.fr> wrote: > > Hi, > > here is my problem. > > Let say have a C++ A class and a Ader class in Python, derived from A > (through boost::python). > I have a list of functions f_i in Ader overloading the equivalent > functions with same name in A. > The main is written in Python and call a method g of a C++ class B passing > and argument of type Ader (it's written as A type under C++, but I don't > have any type issue there). > Let say B::g call a function f_1, calling f_2, calling f_3. The error > occur at f_3 as I could identify it uses A::f_3 instead of Ader::f_3. > By going down, I could confirm that, from f_1 to f_3, all the 3 called > functions are the A version. > So my question is, how can I fix this issue so that the B::g function uses > Ader functions (meanning Python functions) and not A functions? > On a side, this is a C++/Python version of a code working fine when fully > written in C++. > > Christophe Jean-Joseph > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From brandsmeier at gmx.de Thu Apr 19 09:04:04 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Thu, 19 Apr 2012 09:04:04 +0200 Subject: [C++-sig] Re : boost::python: C++/Python function overload issue In-Reply-To: <1334789702.12186.YahooMailNeo@web132302.mail.ird.yahoo.com> References: <1334789702.12186.YahooMailNeo@web132302.mail.ird.yahoo.com> Message-ID: Christophe, You need to work with Wrappers when you export the class A to python. This wrapper will make sure that when C++ calls a class that you overloaded in python that then the correct python implementation is called. See also the sections: Class Virtual Functions Virtual Functions with Default Implementations of the document that JS Unkn0wn gave you: http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/exposing.html -Holger On Thu, Apr 19, 2012 at 00:55, christophe jean-joseph wrote: > > Hi, > > here is my problem. > > Let say have a C++ A class and a Ader class in Python, derived from A > (through boost::python). > I have a list of functions f_i in Ader overloading the equivalent functions > with same name in A. > The main is written in Python and call a method g of a C++ class B passing > and argument of type Ader (it's written as A type under C++, but I don't > have any type issue there). > Let say B::g call a function f_1, calling f_2, calling f_3. The error occur > at f_3 as I could identify it uses A::f_3 instead of Ader::f_3. > By going down, I could confirm that, from f_1 to f_3, all the 3 called > functions are the A version. > So my question is, how can I fix this issue so that the B::g function uses > Ader functions (meanning Python functions) and not A functions? > On a side, this is a C++/Python version of a code working fine when fully > written in C++. > > Christophe Jean-Joseph > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From s_sourceforge at nedprod.com Thu Apr 19 14:48:34 2012 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 19 Apr 2012 13:48:34 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: References: Message-ID: <4F9009A2.6501.4323773@s_sourceforge.nedprod.com> Surely Python absolutely requires DLL support for its extension support? Anything targeted at the Windows API will assume DLL support. You might fare better using a GCC ecosystem. Your proprietary device, I would assume, will use a GCC ecosystem anyway. Niall On 19 Apr 2012 at 0:09, JS Unkn0wn wrote: > -:Background:- > I am working on a cross platform project (Win32 with proprietary graphics > lib, and a proprietary embedded device running a custom OS with custom > compilers) > > -:Goals:- > Using Boost.Python on both platforms (without dlls, as we will have to > embed Python anyway). > > -:Problems:- > Receiving < static runtime is a really bad idea...">> in /MT, which is concerning to me > since compiling as a DLL works but I must be able to deploy this on a > system that has no DLL system. > > -:Setup steps taken so far (in order), and system config:- > 1 - Windows XP Pro + SP3 > 2 - Visual Studio 2008 Standard + Service Pack (C++ and C# installed) > 3 - Python 2.7 installed > 4 - Boost Pro 1.47 installer for Windows installed (c:\boost_1_47) > 5 - Boost 1.47 copied to (c:\boost_1_47_0) > 6 - Boost Build 1.47 downloaded > > ... > > I've written a much more detailed log here ( > http://jsperfunkn0wn.blogspot.co.uk/2012/04/installing-boostpython-python-27-for.html > ). > > Here is the code I am trying to compile: http://pastebin.com/Rg2AeTms > > Regards, > JSPerf Unkn0wn > -- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ From jsperf.unkn0wn at gmail.com Thu Apr 19 15:40:50 2012 From: jsperf.unkn0wn at gmail.com (JS Unkn0wn) Date: Thu, 19 Apr 2012 14:40:50 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: <4F9009A2.6501.4323773@s_sourceforge.nedprod.com> References: <4F9009A2.6501.4323773@s_sourceforge.nedprod.com> Message-ID: Python can be embedded inside the application itself. I'm not looking to extend python with modules available to other scripts other than the scripts loaded by my program. The device uses the ARM compiler (no dynamic linking support, is planned to be added, but not before my product will be released). I've managed to get it compiling for Win32 without requiring DLL's using the steps in this article ( http://goo.gl/iQ7ZY ). I will document my steps in another blog post within the week. What I'm trying to figure out now are fixing the errors explained on my blog entry ( http://goo.gl/K9G36 ). Cheers, JSPerf Unkn0wn On Thu, Apr 19, 2012 at 1:48 PM, Niall Douglas wrote: > Surely Python absolutely requires DLL support for its extension > support? > > Anything targeted at the Windows API will assume DLL support. You > might fare better using a GCC ecosystem. Your proprietary device, I > would assume, will use a GCC ecosystem anyway. > > Niall > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From s_sourceforge at nedprod.com Thu Apr 19 16:41:38 2012 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 19 Apr 2012 15:41:38 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: References: , <4F9009A2.6501.4323773@s_sourceforge.nedprod.com>, Message-ID: <4F902422.11993.499BE03@s_sourceforge.nedprod.com> On 19 Apr 2012 at 14:40, JS Unkn0wn wrote: > What I'm trying to figure out now are fixing the errors explained on my > blog entry ( http://goo.gl/K9G36 ). I think you will struggle to get much help here by posting links to other places. No one here has time to read blogs. You need to formulate the problem into a single post here, preferably with a small example program illustrating the problem. Niall -- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ From jsperf.unkn0wn at gmail.com Thu Apr 19 16:57:57 2012 From: jsperf.unkn0wn at gmail.com (JS Unkn0wn) Date: Thu, 19 Apr 2012 15:57:57 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: <4F902422.11993.499BE03@s_sourceforge.nedprod.com> References: <4F9009A2.6501.4323773@s_sourceforge.nedprod.com> <4F902422.11993.499BE03@s_sourceforge.nedprod.com> Message-ID: On Thu, Apr 19, 2012 at 3:41 PM, Niall Douglas wrote: > > On 19 Apr 2012 at 14:40, JS Unkn0wn wrote: > > > What I'm trying to figure out now are fixing the errors explained on my > > blog entry ( http://goo.gl/K9G36 ). > > I think you will struggle to get much help here by posting links to > other places. No one here has time to read blogs. You need to > formulate the problem into a single post here, preferably with a > small example program illustrating the problem. > > Niall > > -- > Technology & Consulting Services - ned Productions Limited. > http://www.nedproductions.biz/. VAT reg: IE 9708311Q. > Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ > > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig Well it is a blog entry detailing every single step I took, and every decision I made. But I can copy/paste it into here then if that is the only accepted method of communication ... n.b. output.txt, output2.txt, output3.txt and output4.txt is at the end of this message. -: Problem statement :- I am working on a video game on an embedded games system which does not have a .dll system. I want to embed Python into the binary executable and run python scripts that can communicate with the game engine. -: Additional information :- Python 2.7 was compiled with?Visual Studio 2008, which means I don't have to compile Python 2.7 from source in order to use it in my project. You can either?extend?python or?embed?Python. I am?embedding?Python as I will be running this on an embedded system I've actually spent over a?week?so far trying to get this to work (even using Boost.Pro installer) and it seems like such a?painful process. Unfortunately I never kept a?log, but here is a brief summary of errors I do recall: Performing some of the cmd.exe steps in cmd.exe instead of?Visual Studio 2008 Command Prompt Confusing some of the steps given. For example do I perform this step in the boost, boost-build or Boost.Pro-install directory? And why are libs that are supposed to appear in XYZ appearing elsewhere I was getting obscure compile errors at times, and other times I was was able to compile but would suffer from runtime errors when making calls to Python. I've never spent so much time configuring anything to work like this, and unfortunately I have a high level of patience so I'm not giving up yet. -: Final thoughts before I head back to this torturous task :- Why is this so darn difficult? Why can't it just work? or am I the only one in the world who is doing it the wrong way? I could have come up with my own scripting language by now, without half the headache I've had and time wasted. -:Instructions being followed:- I am following?Boost C++ Libraries: Boost.Python Build and Test HOWTO, bearing in mind that it says in?3.1?to (1)Get Boost and (2) Get?bjam, directing us to?1:Get Boost?and?5:Prepare To Use a Boost Library Binary. -: A: Starting setup :- Python 2.7.2 installed (using python installer) Copied boost to c:\boost_1_47_0 Installed BoostPro to c:\boost_1_47_0 Visual Studio 2008 Installed every variant apart from DLL Multithreaded (+debug) Multithreaded static (+debug) Single threaded, static runtime (+debug) Boost Getting Started On Windows?(5.1) says I need all variations of the?Regex?library, so I have run the installer again but to only install all variants. I have also installed the Multithreaded DLL (+dll) Python variants I have "skipped to Section 6" on??Boost Getting Started On Windows?(as directed by 5.1), and successfully executed the Regex sample I have done step 4 of the?3.1: Basic Procedure?and ran?bjam toolset=msvc --verbose-test test?in the command prompt -: Result :- .\bin\msvc-9.0\debug\threading-multi\embedding.exe was created Running?python test_extending.py?yields?output3.txt?(i.e. a?fail) The result is shown in output.txt I ran the MSVC batch file (just to be sure) and which is shown in output2.txt As explained in?3.2: In Case of Trouble, I have created a user-config.jam?file with minimum incantation given. Compiling gives the following?output4.txt?(running?python test_extending.py) still fails, buttest_extending.pyc?is created this time (which I don't think was before) So here I am at?3.2: In Case of Trouble?again, the same place I've been for the past week. I will be asking for help in the cplusplus-sig at python.org?mailing list. BEGIN "output.txt">>> notice: found boost-build.jam at C:/boost_1_47_0/libs/python/example/quickstart/boost-build.jam notice: loading Boost.Build from C:/boost_1_47_0/tools/build/v2 notice: Searching C:\WINDOWS C:\Documents and Settings\Keldon C:\Documents and Settings\Keldon C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 C:/boost_1_47_0/tools/build/v2/kernel C:/boost_1_47_0/tools/build/v2/util C:/boost_1_47_0/tools/build/v2/build C:/boost_1_47_0/tools/build/v2/tools C:/boost_1_47_0/tools/build/v2/contrib C:/boost_1_47_0/tools/build/v2/. for site-config configuration file site-config.jam . notice: Loading site-config configuration file site-config.jam from C:/boost_1_47_0/tools/build/v2/site-config.jam . notice: Searching C:\Documents and Settings\Keldon C:\Documents and Settings\Keldon C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 C:/boost_1_47_0/tools/build/v2/kernel C:/boost_1_47_0/tools/build/v2/util C:/boost_1_47_0/tools/build/v2/build C:/boost_1_47_0/tools/build/v2/tools C:/boost_1_47_0/tools/build/v2/contrib C:/boost_1_47_0/tools/build/v2/. for user-config configuration file user-config.jam . notice: Loading user-config configuration file user-config.jam from C:/Documents and Settings/Keldon/user-config.jam . notice: [msvc-cfg] msvc-9.0 detected, command: 'c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' notice: will use 'c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' for msvc, condition msvc-9.0 notice: [msvc-cfg] condition: 'msvc-9.0//', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0//32', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/32', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0//64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/ia64/', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_ia64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/ia64/64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_ia64 >nul ' notice: [python-cfg] Configuring python... notice: [python-cfg] user-specified version: "2.7" notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\" notice: [python-cfg] Checking interpreter command "python"... notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python27\python.exe" 2>&1' notice: [python-cfg] running command '"python" -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1' notice: [python-cfg] ...requested configuration matched! notice: [python-cfg] Details of this Python configuration: notice: [python-cfg] interpreter command: "python" notice: [python-cfg] include path: "C:\Python27\Include" notice: [python-cfg] library path: "C:\Python27\libs" notice: [python-cfg] DLL search path: "C:\Python27" notice: Searching ../../../.. for project-config configuration file project-config.jam . notice: Loading project-config configuration file project-config.jam from ../../../../project-config.jam . notice: [cmdline-cfg] Detected command-line request for msvc: toolset= msvc version= notice: [cmdline-cfg] toolset msvc already configured notice: iostreams: not using zlib compression notice: iostreams: not using zlib compression notice: iostreams: not using bzip2 compression notice: iostreams: not using bzip2 compression ...patience... ...patience... ...found 1600 targets... ...updating 11 targets... common.mkdir bin common.mkdir bin\msvc-9.0 common.mkdir bin\msvc-9.0\debug common.mkdir bin\msvc-9.0\debug\threading-multi compile-c-c++ bin\msvc-9.0\debug\threading-multi\extending.obj extending.cpp msvc.link.dll bin\msvc-9.0\debug\threading-multi\extending.pyd Creating library bin\msvc-9.0\debug\threading-multi\extending.lib and object bin\msvc-9.0\debug\threading-multi\extending.exp msvc.manifest.dll bin\msvc-9.0\debug\threading-multi\extending.pyd compile-c-c++ bin\msvc-9.0\debug\threading-multi\embedding.obj embedding.cpp msvc.link bin\msvc-9.0\debug\threading-multi\embedding.exe Creating library bin\msvc-9.0\debug\threading-multi\embedding.lib and object bin\msvc-9.0\debug\threading-multi\embedding.exp msvc.manifest bin\msvc-9.0\debug\threading-multi\embedding.exe ...updated 11 targets... <<< output.txt END >>> BEGIN output2.txt notice: found boost-build.jam at C:/boost_1_47_0/libs/python/example/quickstart/boost-build.jam notice: loading Boost.Build from C:/boost_1_47_0/tools/build/v2 notice: Searching C:\WINDOWS C:\Documents and Settings\Keldon C:\Documents and Settings\Keldon C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 C:/boost_1_47_0/tools/build/v2/kernel C:/boost_1_47_0/tools/build/v2/util C:/boost_1_47_0/tools/build/v2/build C:/boost_1_47_0/tools/build/v2/tools C:/boost_1_47_0/tools/build/v2/contrib C:/boost_1_47_0/tools/build/v2/. for site-config configuration file site-config.jam . notice: Loading site-config configuration file site-config.jam from C:/boost_1_47_0/tools/build/v2/site-config.jam . notice: Searching C:\Documents and Settings\Keldon C:\Documents and Settings\Keldon C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 C:/boost_1_47_0/tools/build/v2/kernel C:/boost_1_47_0/tools/build/v2/util C:/boost_1_47_0/tools/build/v2/build C:/boost_1_47_0/tools/build/v2/tools C:/boost_1_47_0/tools/build/v2/contrib C:/boost_1_47_0/tools/build/v2/. for user-config configuration file user-config.jam . notice: Loading user-config configuration file user-config.jam from C:/Documents and Settings/Keldon/user-config.jam . notice: [msvc-cfg] msvc-9.0 detected, command: 'c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' notice: will use 'c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' for msvc, condition msvc-9.0 notice: [msvc-cfg] condition: 'msvc-9.0//', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0//32', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/32', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0//64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/ia64/', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_ia64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/ia64/64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_ia64 >nul ' notice: [python-cfg] Configuring python... notice: [python-cfg] user-specified version: "2.7" notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\" notice: [python-cfg] Checking interpreter command "python"... notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python27\python.exe" 2>&1' notice: [python-cfg] running command '"python" -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1' notice: [python-cfg] ...requested configuration matched! notice: [python-cfg] Details of this Python configuration: notice: [python-cfg] interpreter command: "python" notice: [python-cfg] include path: "C:\Python27\Include" notice: [python-cfg] library path: "C:\Python27\libs" notice: [python-cfg] DLL search path: "C:\Python27" notice: Searching ../../../.. for project-config configuration file project-config.jam . notice: Loading project-config configuration file project-config.jam from ../../../../project-config.jam . notice: [cmdline-cfg] Detected command-line request for msvc: toolset= msvc version= notice: [cmdline-cfg] toolset msvc already configured notice: iostreams: not using zlib compression notice: iostreams: not using zlib compression notice: iostreams: not using bzip2 compression notice: iostreams: not using bzip2 compression ...patience... ...patience... ...found 1600 targets... <<< output2.txt END >>> BEGIN output3.txt Trying: from extending import * Expecting nothing ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 6, in test_extending Failed example: from extending import * Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in from extending import * ImportError: No module named extending Trying: hi = hello('California') Expecting nothing ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 7, in test_extending Failed example: hi = hello('California') Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in hi = hello('California') NameError: name 'hello' is not defined Trying: hi.greet() Expecting: 'Hello from California' ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 8, in test_extending Failed example: hi.greet() Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in hi.greet() NameError: name 'hi' is not defined Trying: invite(hi) Expecting: 'Hello from California! Please come soon!' ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 10, in test_extending Failed example: invite(hi) Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in invite(hi) NameError: name 'invite' is not defined Trying: hi.invite() Expecting: 'Hello from California! Please come soon!' ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 12, in test_extending Failed example: hi.invite() Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in hi.invite() NameError: name 'hi' is not defined Trying: class wordy(hello): def greet(self): return hello.greet(self) + ', where the weather is fine' Expecting nothing ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 15, in test_extending Failed example: class wordy(hello): def greet(self): return hello.greet(self) + ', where the weather is fine' Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in class wordy(hello): NameError: name 'hello' is not defined Trying: hi2 = wordy('Florida') Expecting nothing ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 19, in test_extending Failed example: hi2 = wordy('Florida') Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in hi2 = wordy('Florida') NameError: name 'wordy' is not defined Trying: hi2.greet() Expecting: 'Hello from Florida, where the weather is fine' ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 20, in test_extending Failed example: hi2.greet() Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in hi2.greet() NameError: name 'hi2' is not defined Trying: invite(hi2) Expecting: 'Hello from Florida! Please come soon!' ********************************************************************** File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", line 22, in test_extending Failed example: invite(hi2) Exception raised: Traceback (most recent call last): File "C:\Python27\lib\doctest.py", line 1254, in __run compileflags, 1) in test.globs File "", line 1, in invite(hi2) NameError: name 'invite' is not defined 1 items had no tests: test_extending.run ********************************************************************** 1 items had failures: 9 of 9 in test_extending 9 tests in 2 items. 0 passed and 9 failed. ***Test Failed*** 9 failures. <<< output3.txt END >>> BEGIN output4.txt notice: found boost-build.jam at C:/boost_1_47_0/libs/python/example/quickstart/boost-build.jam notice: loading Boost.Build from C:/boost_1_47_0/tools/build/v2 notice: Searching C:\WINDOWS C:\Documents and Settings\Keldon C:\Documents and Settings\Keldon C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 C:/boost_1_47_0/tools/build/v2/kernel C:/boost_1_47_0/tools/build/v2/util C:/boost_1_47_0/tools/build/v2/build C:/boost_1_47_0/tools/build/v2/tools C:/boost_1_47_0/tools/build/v2/contrib C:/boost_1_47_0/tools/build/v2/. for site-config configuration file site-config.jam . notice: Loading site-config configuration file site-config.jam from C:/boost_1_47_0/tools/build/v2/site-config.jam . notice: Searching C:\Documents and Settings\Keldon C:\Documents and Settings\Keldon C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 C:/boost_1_47_0/tools/build/v2/kernel C:/boost_1_47_0/tools/build/v2/util C:/boost_1_47_0/tools/build/v2/build C:/boost_1_47_0/tools/build/v2/tools C:/boost_1_47_0/tools/build/v2/contrib C:/boost_1_47_0/tools/build/v2/. for user-config configuration file user-config.jam . notice: Loading user-config configuration file user-config.jam from C:/Documents and Settings/Keldon/user-config.jam . notice: [python-cfg] Configuring python... notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\" notice: [python-cfg] Checking interpreter command "python"... notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python27\python.exe" 2>&1' notice: [python-cfg] running command '"python" -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1' notice: [python-cfg] ...requested configuration matched! notice: [python-cfg] Details of this Python configuration: notice: [python-cfg] interpreter command: "python" notice: [python-cfg] include path: "C:\Python27\Include" notice: [python-cfg] library path: "C:\Python27\libs" notice: [python-cfg] DLL search path: "C:\Python27" notice: Searching ../../../.. for project-config configuration file project-config.jam . notice: Loading project-config configuration file project-config.jam from ../../../../project-config.jam . notice: [msvc-cfg] msvc-9.0 detected, command: 'c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' notice: will use 'c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' for msvc, condition msvc-9.0 notice: [msvc-cfg] condition: 'msvc-9.0//', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0//32', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/32', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0//64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/x86/64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/ia64/', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_ia64 >nul ' notice: [msvc-cfg] condition: 'msvc-9.0/ia64/64', setup: 'call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_ia64 >nul ' notice: [cmdline-cfg] Detected command-line request for msvc: toolset= msvc version= notice: [cmdline-cfg] toolset msvc already configured notice: iostreams: not using zlib compression notice: iostreams: not using zlib compression notice: iostreams: not using bzip2 compression notice: iostreams: not using bzip2 compression ...patience... ...patience... ...found 1600 targets... <<< output4.txt END From s_sourceforge at nedprod.com Thu Apr 19 17:10:35 2012 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 19 Apr 2012 16:10:35 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: References: , <4F902422.11993.499BE03@s_sourceforge.nedprod.com>, Message-ID: <4F902AEB.4852.4B43E50@s_sourceforge.nedprod.com> So, to be clear, your problem has absolutely nothing to do with any embedded system. Your sole problem is that you can't get embedding to work on Windows? Niall On 19 Apr 2012 at 15:57, JS Unkn0wn wrote: > On Thu, Apr 19, 2012 at 3:41 PM, Niall Douglas > wrote: > > > > On 19 Apr 2012 at 14:40, JS Unkn0wn wrote: > > > > > What I'm trying to figure out now are fixing the errors explained on my > > > blog entry ( http://goo.gl/K9G36 ). > > > > I think you will struggle to get much help here by posting links to > > other places. No one here has time to read blogs. You need to > > formulate the problem into a single post here, preferably with a > > small example program illustrating the problem. > > > > Niall > > > > -- > > Technology & Consulting Services - ned Productions Limited. > > http://www.nedproductions.biz/. VAT reg: IE 9708311Q. > > Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ > > > > > > > > _______________________________________________ > > Cplusplus-sig mailing list > > Cplusplus-sig at python.org > > http://mail.python.org/mailman/listinfo/cplusplus-sig > > Well it is a blog entry detailing every single step I took, and every > decision I made. But I can copy/paste it into here then if that is the > only accepted method of communication ... > n.b. output.txt, output2.txt, output3.txt and output4.txt is at the > end of this message. > > -: Problem statement :- > > I am working on a video game on an embedded games system which does > not have a .dll system. I want to embed Python into the binary > executable and run python scripts that can communicate with the game > engine. > > -: Additional information :- > > Python 2.7 was compiled with?Visual Studio 2008, which means I don't > have to compile Python 2.7 from source in order to use it in my > project. > You can either?extend?python or?embed?Python. I am?embedding?Python as > I will be running this on an embedded system > I've actually spent over a?week?so far trying to get this to work > (even using Boost.Pro installer) and it seems like such a?painful > process. Unfortunately I never kept a?log, but here is a brief summary > of errors I do recall: > > Performing some of the cmd.exe steps in cmd.exe instead of?Visual > Studio 2008 Command Prompt > Confusing some of the steps given. For example do I perform this step > in the boost, boost-build or Boost.Pro-install directory? And why are > libs that are supposed to appear in XYZ appearing elsewhere > > I was getting obscure compile errors at times, and other times I was > was able to compile but would suffer from runtime errors when making > calls to Python. I've never spent so much time configuring anything to > work like this, and unfortunately I have a high level of patience so > I'm not giving up yet. > > -: Final thoughts before I head back to this torturous task :- > > Why is this so darn difficult? Why can't it just work? or am I the > only one in the world who is doing it the wrong way? I could have come > up with my own scripting language by now, without half the headache > I've had and time wasted. > > -:Instructions being followed:- > > I am following?Boost C++ Libraries: Boost.Python Build and Test HOWTO, > bearing in mind that it says in?3.1?to (1)Get Boost and (2) Get?bjam, > directing us to?1:Get Boost?and?5:Prepare To Use a Boost Library > Binary. > > -: A: Starting setup :- > > Python 2.7.2 installed (using python installer) > Copied boost to c:\boost_1_47_0 > Installed BoostPro to c:\boost_1_47_0 > > Visual Studio 2008 > Installed every variant apart from DLL > > Multithreaded (+debug) > Multithreaded static (+debug) > Single threaded, static runtime (+debug) > > Boost Getting Started On Windows?(5.1) says I need all variations of > the?Regex?library, so I have run the installer again but to only > install all variants. > I have also installed the Multithreaded DLL (+dll) Python variants > I have "skipped to Section 6" on??Boost Getting Started On Windows?(as > directed by 5.1), and successfully executed the Regex sample > I have done step 4 of the?3.1: Basic Procedure?and ran?bjam > toolset=msvc --verbose-test test?in the command prompt > > -: Result :- > > .\bin\msvc-9.0\debug\threading-multi\embedding.exe was created > Running?python test_extending.py?yields?output3.txt?(i.e. a?fail) > > The result is shown in output.txt > I ran the MSVC batch file (just to be sure) and which is shown in output2.txt > > As explained in?3.2: In Case of Trouble, I have created a > user-config.jam?file with minimum incantation given. Compiling gives > the following?output4.txt?(running?python test_extending.py) still > fails, buttest_extending.pyc?is created this time (which I don't think > was before) > > So here I am at?3.2: In Case of Trouble?again, the same place I've > been for the past week. I will be asking for help in the > cplusplus-sig at python.org?mailing list. > > BEGIN "output.txt">>> > notice: found boost-build.jam at > C:/boost_1_47_0/libs/python/example/quickstart/boost-build.jam > notice: loading Boost.Build from C:/boost_1_47_0/tools/build/v2 > notice: Searching C:\WINDOWS C:\Documents and Settings\Keldon > C:\Documents and Settings\Keldon > C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 > C:/boost_1_47_0/tools/build/v2/kernel > C:/boost_1_47_0/tools/build/v2/util > C:/boost_1_47_0/tools/build/v2/build > C:/boost_1_47_0/tools/build/v2/tools > C:/boost_1_47_0/tools/build/v2/contrib > C:/boost_1_47_0/tools/build/v2/. for site-config configuration file > site-config.jam . > notice: Loading site-config configuration file site-config.jam from > C:/boost_1_47_0/tools/build/v2/site-config.jam . > notice: Searching C:\Documents and Settings\Keldon C:\Documents and > Settings\Keldon > C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 > C:/boost_1_47_0/tools/build/v2/kernel > C:/boost_1_47_0/tools/build/v2/util > C:/boost_1_47_0/tools/build/v2/build > C:/boost_1_47_0/tools/build/v2/tools > C:/boost_1_47_0/tools/build/v2/contrib > C:/boost_1_47_0/tools/build/v2/. for user-config configuration file > user-config.jam . > notice: Loading user-config configuration file user-config.jam from > C:/Documents and Settings/Keldon/user-config.jam . > notice: [msvc-cfg] msvc-9.0 detected, command: 'c:\Program > Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' > notice: will use 'c:\Program Files\Microsoft Visual Studio > 9.0\VC\bin\cl.exe' for msvc, condition msvc-9.0 > notice: [msvc-cfg] condition: > 'msvc-9.0//', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0//32', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/32', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0//64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_amd64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_amd64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/ia64/', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_ia64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/ia64/64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_ia64 >nul > ' > notice: [python-cfg] Configuring python... > notice: [python-cfg] user-specified version: "2.7" > notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\" > notice: [python-cfg] Checking interpreter command "python"... > notice: [python-cfg] running command 'DIR /-C /A:S > "C:\Python27\python.exe" 2>&1' > notice: [python-cfg] running command '"python" -c "from sys import *; > print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' > % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" > 2>&1' > notice: [python-cfg] ...requested configuration matched! > notice: [python-cfg] Details of this Python configuration: > notice: [python-cfg] interpreter command: "python" > notice: [python-cfg] include path: "C:\Python27\Include" > notice: [python-cfg] library path: "C:\Python27\libs" > notice: [python-cfg] DLL search path: "C:\Python27" > notice: Searching ../../../.. for project-config configuration file > project-config.jam . > notice: Loading project-config configuration file project-config.jam > from ../../../../project-config.jam . > notice: [cmdline-cfg] Detected command-line request for msvc: toolset= > msvc version= > notice: [cmdline-cfg] toolset msvc already configured > notice: iostreams: not using zlib compression > notice: iostreams: not using zlib compression > notice: iostreams: not using bzip2 compression > notice: iostreams: not using bzip2 compression > ...patience... > ...patience... > ...found 1600 targets... > ...updating 11 targets... > common.mkdir bin > common.mkdir bin\msvc-9.0 > common.mkdir bin\msvc-9.0\debug > common.mkdir bin\msvc-9.0\debug\threading-multi > compile-c-c++ bin\msvc-9.0\debug\threading-multi\extending.obj > extending.cpp > msvc.link.dll bin\msvc-9.0\debug\threading-multi\extending.pyd > Creating library bin\msvc-9.0\debug\threading-multi\extending.lib > and object bin\msvc-9.0\debug\threading-multi\extending.exp > msvc.manifest.dll bin\msvc-9.0\debug\threading-multi\extending.pyd > compile-c-c++ bin\msvc-9.0\debug\threading-multi\embedding.obj > embedding.cpp > msvc.link bin\msvc-9.0\debug\threading-multi\embedding.exe > Creating library bin\msvc-9.0\debug\threading-multi\embedding.lib > and object bin\msvc-9.0\debug\threading-multi\embedding.exp > msvc.manifest bin\msvc-9.0\debug\threading-multi\embedding.exe > ...updated 11 targets... > <<< output.txt END > > >>> BEGIN output2.txt > notice: found boost-build.jam at > C:/boost_1_47_0/libs/python/example/quickstart/boost-build.jam > notice: loading Boost.Build from C:/boost_1_47_0/tools/build/v2 > notice: Searching C:\WINDOWS C:\Documents and Settings\Keldon > C:\Documents and Settings\Keldon > C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 > C:/boost_1_47_0/tools/build/v2/kernel > C:/boost_1_47_0/tools/build/v2/util > C:/boost_1_47_0/tools/build/v2/build > C:/boost_1_47_0/tools/build/v2/tools > C:/boost_1_47_0/tools/build/v2/contrib > C:/boost_1_47_0/tools/build/v2/. for site-config configuration file > site-config.jam . > notice: Loading site-config configuration file site-config.jam from > C:/boost_1_47_0/tools/build/v2/site-config.jam . > notice: Searching C:\Documents and Settings\Keldon C:\Documents and > Settings\Keldon > C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 > C:/boost_1_47_0/tools/build/v2/kernel > C:/boost_1_47_0/tools/build/v2/util > C:/boost_1_47_0/tools/build/v2/build > C:/boost_1_47_0/tools/build/v2/tools > C:/boost_1_47_0/tools/build/v2/contrib > C:/boost_1_47_0/tools/build/v2/. for user-config configuration file > user-config.jam . > notice: Loading user-config configuration file user-config.jam from > C:/Documents and Settings/Keldon/user-config.jam . > notice: [msvc-cfg] msvc-9.0 detected, command: 'c:\Program > Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' > notice: will use 'c:\Program Files\Microsoft Visual Studio > 9.0\VC\bin\cl.exe' for msvc, condition msvc-9.0 > notice: [msvc-cfg] condition: > 'msvc-9.0//', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0//32', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/32', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0//64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_amd64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_amd64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/ia64/', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_ia64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/ia64/64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_ia64 >nul > ' > notice: [python-cfg] Configuring python... > notice: [python-cfg] user-specified version: "2.7" > notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\" > notice: [python-cfg] Checking interpreter command "python"... > notice: [python-cfg] running command 'DIR /-C /A:S > "C:\Python27\python.exe" 2>&1' > notice: [python-cfg] running command '"python" -c "from sys import *; > print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' > % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" > 2>&1' > notice: [python-cfg] ...requested configuration matched! > notice: [python-cfg] Details of this Python configuration: > notice: [python-cfg] interpreter command: "python" > notice: [python-cfg] include path: "C:\Python27\Include" > notice: [python-cfg] library path: "C:\Python27\libs" > notice: [python-cfg] DLL search path: "C:\Python27" > notice: Searching ../../../.. for project-config configuration file > project-config.jam . > notice: Loading project-config configuration file project-config.jam > from ../../../../project-config.jam . > notice: [cmdline-cfg] Detected command-line request for msvc: toolset= > msvc version= > notice: [cmdline-cfg] toolset msvc already configured > notice: iostreams: not using zlib compression > notice: iostreams: not using zlib compression > notice: iostreams: not using bzip2 compression > notice: iostreams: not using bzip2 compression > ...patience... > ...patience... > ...found 1600 targets... > <<< output2.txt END > > >>> BEGIN output3.txt > Trying: > from extending import * > Expecting nothing > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 6, in test_extending > Failed example: > from extending import * > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > from extending import * > ImportError: No module named extending > Trying: > hi = hello('California') > Expecting nothing > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 7, in test_extending > Failed example: > hi = hello('California') > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > hi = hello('California') > NameError: name 'hello' is not defined > Trying: > hi.greet() > Expecting: > 'Hello from California' > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 8, in test_extending > Failed example: > hi.greet() > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > hi.greet() > NameError: name 'hi' is not defined > Trying: > invite(hi) > Expecting: > 'Hello from California! Please come soon!' > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 10, in test_extending > Failed example: > invite(hi) > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > invite(hi) > NameError: name 'invite' is not defined > Trying: > hi.invite() > Expecting: > 'Hello from California! Please come soon!' > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 12, in test_extending > Failed example: > hi.invite() > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > hi.invite() > NameError: name 'hi' is not defined > Trying: > class wordy(hello): > def greet(self): > return hello.greet(self) + ', where the weather is fine' > Expecting nothing > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 15, in test_extending > Failed example: > class wordy(hello): > def greet(self): > return hello.greet(self) + ', where the weather is fine' > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > class wordy(hello): > NameError: name 'hello' is not defined > Trying: > hi2 = wordy('Florida') > Expecting nothing > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 19, in test_extending > Failed example: > hi2 = wordy('Florida') > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > hi2 = wordy('Florida') > NameError: name 'wordy' is not defined > Trying: > hi2.greet() > Expecting: > 'Hello from Florida, where the weather is fine' > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 20, in test_extending > Failed example: > hi2.greet() > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > hi2.greet() > NameError: name 'hi2' is not defined > Trying: > invite(hi2) > Expecting: > 'Hello from Florida! Please come soon!' > ********************************************************************** > File "C:\boost_1_47_0\libs\python\example\quickstart\test_extending.py", > line 22, in test_extending > Failed example: > invite(hi2) > Exception raised: > Traceback (most recent call last): > File "C:\Python27\lib\doctest.py", line 1254, in __run > compileflags, 1) in test.globs > File "", line 1, in > invite(hi2) > NameError: name 'invite' is not defined > 1 items had no tests: > test_extending.run > ********************************************************************** > 1 items had failures: > 9 of 9 in test_extending > 9 tests in 2 items. > 0 passed and 9 failed. > ***Test Failed*** 9 failures. > <<< output3.txt END > > >>> BEGIN output4.txt > notice: found boost-build.jam at > C:/boost_1_47_0/libs/python/example/quickstart/boost-build.jam > notice: loading Boost.Build from C:/boost_1_47_0/tools/build/v2 > notice: Searching C:\WINDOWS C:\Documents and Settings\Keldon > C:\Documents and Settings\Keldon > C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 > C:/boost_1_47_0/tools/build/v2/kernel > C:/boost_1_47_0/tools/build/v2/util > C:/boost_1_47_0/tools/build/v2/build > C:/boost_1_47_0/tools/build/v2/tools > C:/boost_1_47_0/tools/build/v2/contrib > C:/boost_1_47_0/tools/build/v2/. for site-config configuration file > site-config.jam . > notice: Loading site-config configuration file site-config.jam from > C:/boost_1_47_0/tools/build/v2/site-config.jam . > notice: Searching C:\Documents and Settings\Keldon C:\Documents and > Settings\Keldon > C:\boost_1_47_0\libs\python\example\quickstart\../../../../tools/build/v2 > C:/boost_1_47_0/tools/build/v2/kernel > C:/boost_1_47_0/tools/build/v2/util > C:/boost_1_47_0/tools/build/v2/build > C:/boost_1_47_0/tools/build/v2/tools > C:/boost_1_47_0/tools/build/v2/contrib > C:/boost_1_47_0/tools/build/v2/. for user-config configuration file > user-config.jam . > notice: Loading user-config configuration file user-config.jam from > C:/Documents and Settings/Keldon/user-config.jam . > notice: [python-cfg] Configuring python... > notice: [python-cfg] Registry indicates Python 2.7 installed at "C:\Python27\" > notice: [python-cfg] Checking interpreter command "python"... > notice: [python-cfg] running command 'DIR /-C /A:S > "C:\Python27\python.exe" 2>&1' > notice: [python-cfg] running command '"python" -c "from sys import *; > print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' > % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" > 2>&1' > notice: [python-cfg] ...requested configuration matched! > notice: [python-cfg] Details of this Python configuration: > notice: [python-cfg] interpreter command: "python" > notice: [python-cfg] include path: "C:\Python27\Include" > notice: [python-cfg] library path: "C:\Python27\libs" > notice: [python-cfg] DLL search path: "C:\Python27" > notice: Searching ../../../.. for project-config configuration file > project-config.jam . > notice: Loading project-config configuration file project-config.jam > from ../../../../project-config.jam . > notice: [msvc-cfg] msvc-9.0 detected, command: 'c:\Program > Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe' > notice: will use 'c:\Program Files\Microsoft Visual Studio > 9.0\VC\bin\cl.exe' for msvc, condition msvc-9.0 > notice: [msvc-cfg] condition: > 'msvc-9.0//', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0//32', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/32', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 > >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0//64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_amd64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/x86/64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_amd64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/ia64/', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_ia64 >nul > ' > notice: [msvc-cfg] condition: > 'msvc-9.0/ia64/64', setup: 'call > "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" > x86_ia64 >nul > ' > notice: [cmdline-cfg] Detected command-line request for msvc: toolset= > msvc version= > notice: [cmdline-cfg] toolset msvc already configured > notice: iostreams: not using zlib compression > notice: iostreams: not using zlib compression > notice: iostreams: not using bzip2 compression > notice: iostreams: not using bzip2 compression > ...patience... > ...patience... > ...found 1600 targets... > <<< output4.txt END > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig -- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ From jsperf.unkn0wn at gmail.com Thu Apr 19 17:30:07 2012 From: jsperf.unkn0wn at gmail.com (JS Unkn0wn) Date: Thu, 19 Apr 2012 16:30:07 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: <4F902AEB.4852.4B43E50@s_sourceforge.nedprod.com> References: <4F902422.11993.499BE03@s_sourceforge.nedprod.com> <4F902AEB.4852.4B43E50@s_sourceforge.nedprod.com> Message-ID: Yes, my current problem is embedding on Windows, but my requirements are the same as compiling to the embedded system, as the primary target is with the Arm processor + proprietary OS. The Windows compilation is just a temporary set up until my kit arrives. So I have planned for the Windows build to work with the same limitations that I would be subjected to with the hardware. Until I receive my hardware development kit I am working with a Windows substitute environment that provides an OpenGL interface that emulates the Pica200 GPU. Though I'm only mentioning that to explain why I have to statically link against Python and Boost.Python and have no other option. I have already achieved my goal of statically linking Boost.Python and Python (or at least it appears to). My goal right now is to successfully compile and run "%BOOST_DIR%\libs\python\example\quickstart", as I really like to have all of my tools in order and I would not be comfortable knowing that I cannot successfully operate my tool. p.s. many thanks for being so helpful. Regards, JSPerf Unkn0wn From s_sourceforge at nedprod.com Thu Apr 19 18:00:18 2012 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 19 Apr 2012 17:00:18 +0100 Subject: [C++-sig] Python.Boost + Python2.7 + VS2008 issues In-Reply-To: References: , <4F902AEB.4852.4B43E50@s_sourceforge.nedprod.com>, Message-ID: <4F903692.15051.4E1C26A@s_sourceforge.nedprod.com> On 19 Apr 2012 at 16:30, JS Unkn0wn wrote: > Yes, my current problem is embedding on Windows, but my requirements > are the same as compiling to the embedded system, as the primary > target is with the Arm processor + proprietary OS. The Windows > compilation is just a temporary set up until my kit arrives. So I have > planned for the Windows build to work with the same limitations that I > would be subjected to with the hardware. Sure I get all this. However, from our list's perspective, all the embedded processor stuff is a completely separate issue that isn't important here. > Until I receive my hardware development kit I am working with a > Windows substitute environment that provides an OpenGL interface that > emulates the Pica200 GPU. Though I'm only mentioning that to explain > why I have to statically link against Python and Boost.Python and have > no other option. It's okay, just say you want to statically link everything. No other explanation needed unless it may cause the bug. > I have already achieved my goal of statically linking Boost.Python and > Python (or at least it appears to). My goal right now is to > successfully compile and run > "%BOOST_DIR%\libs\python\example\quickstart", as I really like to have > all of my tools in order and I would not be comfortable knowing that I > cannot successfully operate my tool. Firstly, the MSVC toolset is VERY different to the GCC toolset. You'll find static linking harder on MSVC in general. Secondly, just because you get it working on MSVC has little to no bearing on whether it will work on GCC. Thirdly, you are almost certainly cross-compiling given that target CPU, so just because it works on GCC or MSVC has not much relevance to whether it will work cross-compiled. This is because your target system probably is a partial native POSIX implementation with all sorts of non-POSIX oddities, whereas GCC emulates a POSIX environment on Windows and MSVC isn't POSIX at all. On that basis, I'd strongly suggest you forget about trying this on Windows. Try it on Linux or BSD instead using GCC. They're both native POSIX, and if it works there you have some chance it might work on your target board. Even better, once you have it working on native Linux or BSD, try cross compiling to ARM and firing it off to an emulated ARM. Or, if you can afford it, simply buy an ARM computer outright, install Debian squeeze and work on that. Now past all of the above of using the right tool for the job, probably your errors come from failure to find libraries because the search paths are screwed up. Try looking into PYTHONPATH or overriding sys.path in python. If you have no DLL/SO support, python probably has an __import__ override which is linking in static libraries by poking them in as an import emulation. That import override probably isn't very intelligent, and may be getting confused. I don't think BPL is even ZIP archive aware/aware of packages and the package management runtime? That I'm not sure on. If it isn't, and I suspect it isn't given BPL's age, BPL could well be making an assumption that module loading always comes from the filing system. Food for thought anyway. Niall -- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Work Portfolio: http://careers.stackoverflow.com/nialldouglas/ From eudoxos at arcig.cz Fri Apr 20 09:55:29 2012 From: eudoxos at arcig.cz (=?utf-8?b?VsOhY2xhdg==?= =?utf-8?b?xaBtaWxhdWVy?=) Date: Fri, 20 Apr 2012 07:55:29 +0000 (UTC) Subject: [C++-sig] =?utf-8?q?No_automatic_upcasting_with_std=3A=3Ashared?= =?utf-8?q?=5Fptr_in_function_calls=3F?= Message-ID: Hello, I have a sample hierarchy of polymorphic classes (A from which B inherits). One of them (A1, B1) is managed with boost::shared_ptr, the other one (A2, B2) via std::shared_ptr (I defined the get_pointer template for std::shared_ptr). When I call f1(boost::shared_ptr) with an object B1 from python, it is correctly upcast to the pointer to its base class and the c++ function is called. When I call f2(std::shared_ptr) with B2 argument from python, no upcasting takes place and I get Boost.Python.Argument error. The code is here: foo.cpp: #include /// make boost::python understand std::shared_ptr #include namespace boost { template T* get_pointer(std::shared_ptr p){ return p.get(); } } // define a hierarchy struct A1{ virtual ~A1(){} }; struct B1: public A1{ virtual ~B1(){} }; void f1(boost::shared_ptr ptr){ std::cerr<<"f1()"< ptr){ std::cerr<<"f2()"< using namespace boost::python; BOOST_PYTHON_MODULE(foo){ class_>("A1"); class_,bases>("B1"); def("f1",f1); class_>("A2"); class_,bases>("B2"); def("f2",f2); } compiling with (under Linux): g++ -std=c++0x foo.cpp -o foo.so -fPIC -shared -lboost_python `pkg-config python --libs --cflags` Running PYTHONPATH=. python -c "import foo; foo.f1(foo.B1()); foo.f2(foo.B2());" I obtain: f1() Traceback (most recent call last): File "", line 1, in Boost.Python.ArgumentError: Python argument types in foo.f2(B2) did not match C++ signature: f2(std::shared_ptr) Where is the problem? Cheers, Vaclav From jjchristophe at yahoo.fr Fri Apr 20 17:15:52 2012 From: jjchristophe at yahoo.fr (christophe jean-joseph) Date: Fri, 20 Apr 2012 16:15:52 +0100 (BST) Subject: [C++-sig] Re : Re : boost::python: C++/Python function overload issue In-Reply-To: References: <1334789702.12186.YahooMailNeo@web132302.mail.ird.yahoo.com> Message-ID: <1334934952.93051.YahooMailNeo@web132306.mail.ird.yahoo.com> Thank you very much. I knew the link already but it made me read my code again and realize that I forgot to reflect the overloaded functions with boost::python. Christophe Jean-Joseph ________________________________ De?: JS Unkn0wn ??: christophe jean-joseph ; Development of Python/C++ integration Envoy? le : Jeudi 19 avril 2012 1h21 Objet?: Re: [C++-sig] Re : boost::python: C++/Python function overload issue Does this (? http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/exposing.html? )?answer your question? specifically "Class Virtual Functions". On Wed, Apr 18, 2012 at 11:55 PM, christophe jean-joseph wrote: > >Hi, > > >here is my problem. > > >Let say have a C++ A class and a Ader class in Python, derived from A (through boost::python). >I have a list of functions f_i in Ader overloading the equivalent functions with same name in A. >The main is written in Python and call a method g of a C++ class B passing and argument of type Ader (it's written as A type under C++, but I don't have any type issue there). >Let say B::g call a function f_1, calling f_2, calling f_3. The error occur at f_3 as I could identify it uses A::f_3 instead of Ader::f_3. >By going down, I could confirm that, from f_1 to f_3, all the 3 called functions are the A version.? >So my question is, how can I fix this issue so that the B::g function uses Ader functions (meanning Python functions) and not A functions? >On a side, this is a C++/Python version of a code working fine when fully written in C++. > >Christophe Jean-Joseph >? >_______________________________________________ >Cplusplus-sig mailing list >Cplusplus-sig at python.org >http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From helferthomas at free.fr Fri Apr 20 17:45:37 2012 From: helferthomas at free.fr (Helfer Thomas) Date: Fri, 20 Apr 2012 17:45:37 +0200 Subject: [C++-sig] boost python writing converters for list to std::vector Message-ID: <1334936737.1940.5.camel@asus-virg> Hi, using http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/, I tried to write a converter for list to std::vector (In the example, T will be double). The code (see converter.cxx) I wrote is still in early stage of development (no check) but compiles fine on ubuntu oneiric with boost python 1.46. I used it to create an std module. However, a simple test (see test.py) does not work as exepted. Did I misunderstood something or does boost have a special treatment for the list object which bypasses converters ? Thanks for any help, Sincerly, Helfer THomas -------------- next part -------------- A non-text attachment was scrubbed... Name: converter.cxx Type: text/x-c++src Size: 2663 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.py Type: text/x-python Size: 33 bytes Desc: not available URL: From brandsmeier at gmx.de Sun Apr 22 21:42:47 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Sun, 22 Apr 2012 21:42:47 +0200 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python Message-ID: Dear list, how is it possible to have a class in C++ that can be extended from python and that stores a weak_ptr to itself? The reason why I want to do this: - using a weak_ptr to itself does not introduce a memory leak. - from a C++-member of that class I can call other functions that expect a shared_ptr<>, in that case I convert the weak_ptr to a shared_ptr and all the memory management works nicely. The way I would suspect this to work is: struct I { void setThisRCP(boost::shared_ptr ptr) { thisRCP = ptr; } boost::shared_ptr getThisRCP() const { return thisRCP.lock(); } boost::weak_ptr thisRCP; }; Then I export this class to C++ and in python I would do: class IDer(I): def __init__(self): I.__init__(self) self.setThisRCP(self) And I would suspect that I can use that class now in C++ and in particular calling getThisRCP() from C++ returns a valid shared pointer. However, immediately after the call of `self.setThisRCP(self)` the weak_ptr is already invalid and getThisRCP returns an shared pointer to Null (None in python). Attached to this message is a very simple example that demonstrates how this failes for the above implementation, the ouptu for the snipped: print '\ntestcase for thisRCP as from python extended class:' i = IDer() assert i.getThisRCP() is not None fails the assertion. However if I do the equivalent to IDer purely in C++ (which is not really an option) then everything works (see attachment) with the putput testcase for thisRCP as set from C++: 42 destructor for J called ... I suspect that the error comes from the fact that boost python create as temporary shared_ptr that is passes to setThisRCP() which is not the shared pointer that actually holds the instance of IDer in python (is it actually hold as a shared_ptr?). Do you have any proposal of how I can implement the above pattern with boost python? Or is this completly impossible at the moment? I also reported this issue before "storing weak_ptr to this in classes extended from python" but at that time I wasn't using shared_ptr and now I really suffer from the memory leak that was introduced by my workaround which was to store the thisRCP as a "shared_ptr" and I really need to fix that now. So here is a small little example that does not depend on any other parts of my library. -Holger -------------- next part -------------- A non-text attachment was scrubbed... Name: thisRCPPy.cpp Type: text/x-c++src Size: 1973 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test_rcp.py Type: application/octet-stream Size: 383 bytes Desc: not available URL: From talljimbo at gmail.com Mon Apr 23 17:10:13 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Mon, 23 Apr 2012 11:10:13 -0400 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: <4F9570D5.4040701@gmail.com> On 04/22/2012 03:42 PM, Holger Brandsmeier wrote: > Dear list, > > how is it possible to have a class in C++ that can be extended from > python and that stores a weak_ptr to itself? > > The reason why I want to do this: > - using a weak_ptr to itself does not introduce a memory leak. > - from a C++-member of that class I can call other functions that > expect a shared_ptr<>, in that case I convert the weak_ptr to a > shared_ptr and all the memory management works nicely. > > The way I would suspect this to work is: > struct I { > void setThisRCP(boost::shared_ptr ptr) { > thisRCP = ptr; > } > > boost::shared_ptr getThisRCP() const { > return thisRCP.lock(); > } > > boost::weak_ptr thisRCP; > }; > > Then I export this class to C++ and in python I would do: > class IDer(I): > def __init__(self): > I.__init__(self) > self.setThisRCP(self) > > And I would suspect that I can use that class now in C++ and in > particular calling getThisRCP() from C++ returns a valid shared > pointer. However, immediately after the call of > `self.setThisRCP(self)` the weak_ptr is already invalid and getThisRCP > returns an shared pointer to Null (None in python). > > Attached to this message is a very simple example that demonstrates > how this failes for the above implementation, the ouptu for the > snipped: > > print '\ntestcase for thisRCP as from python extended class:' > i = IDer() > assert i.getThisRCP() is not None > > fails the assertion. However if I do the equivalent to IDer purely in > C++ (which is not really an option) then everything works (see > attachment) with the putput > testcase for thisRCP as set from C++: > 42 > destructor for J called ... > > I suspect that the error comes from the fact that boost python create > as temporary shared_ptr that is passes to setThisRCP() which is not > the shared pointer that actually holds the instance of IDer in python > (is it actually hold as a shared_ptr?). > > Do you have any proposal of how I can implement the above pattern with > boost python? Or is this completly impossible at the moment? > I agree with your suspicion about what's going on here, though I haven't (yet) tested your example. One quick thing to try would be having setThisRCP() take a shared_ptr by reference - that should force Boost.Python to try to return the internal shared_ptr rather than create a temporary one. Even if it fails, you may learn something about what's going on. > I also reported this issue before "storing weak_ptr to this in classes > extended from python" but at that time I wasn't using shared_ptr and > now I really suffer from the memory leak that was introduced by my > workaround which was to store the thisRCP as a "shared_ptr" and I > really need to fix that now. So here is a small little example that > does not depend on any other parts of my library. > Thanks for the small example. Hopefully we can get to the bottom of this; you don't seem to be the only person who wants to do something like this. Jim From talljimbo at gmail.com Mon Apr 23 17:21:55 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Mon, 23 Apr 2012 11:21:55 -0400 Subject: [C++-sig] boost::python: marshalling buffers In-Reply-To: References: Message-ID: <4F957393.3030902@gmail.com> On 04/18/2012 01:57 PM, Christoph Rupp wrote: > Hi, > > i have a C++ class that i'm wrapping with boost::python: > > class Foo { > // ... > const char *get_buffer(); > size_t get_size() const; > // ... > }; > > I want to send this class through a thrift interface (which uses the > write() method to send the data to a file or a socket). For a few days now > i'm trying to implement this. By now i understand that i have to implement > the buffer protocol, and i know that i can create a buffer with > boost::python (read-only access is sufficient): > > inline object as_buffer(const Foo&f) { > return object (handle<> (PyBuffer_FromMemory ((void*)f.get_buffer(), > f.get_size()))); > } > > (This is based on an email from 2009 that i found in this mailing list's > archive.) > > But i do not know how to glue it together to form a full module. This is > how the module looks right now: > > BOOST_PYTHON_MODULE(Foo) > { > class_("Foo", > init()) > .def("add", afn) > .def("finalize",&Foo::finalize) > .def("empty",&Foo::empty) > .def("clear",&Foo::clear) > ; > } > > How can i include that buffer conversion? > Sorry about the long delay in a reply, but I'm afraid that right now it looks *really* tricky (possibly impossible) to add the buffer protocol to a Boost.Python class. Python doesn't have a special named methods for the buffer protocol: http://stackoverflow.com/questions/2079272/which-methods-implement-the-buffer-interface-in-python And Boost.Python doesn't give you access to the PyTypeObject structure where you'd be able to add the PyBufferProcs slots. I think you have two options: - Wrap your buffer-getter function with another name and find a way to get your serialization code to use that. - Wrap this class class using the raw Python C-API and use Boost.Python custom lvalue converters to make it work with any Boost.Python-wrapped code you have. You could use Boost.Python to wrap all the member functions, for instance, and add them to the Python C-API class's dict. Neither option is great, but hopefully one will allow you to move forward. HTH! Jim From talljimbo at gmail.com Mon Apr 23 17:28:46 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Mon, 23 Apr 2012 11:28:46 -0400 Subject: [C++-sig] boost python writing converters for list to std::vector In-Reply-To: <1334936737.1940.5.camel@asus-virg> References: <1334936737.1940.5.camel@asus-virg> Message-ID: <4F95752E.1010701@gmail.com> On 04/20/2012 11:45 AM, Helfer Thomas wrote: > Hi, > > using > http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/, I tried to write a converter for list to std::vector (In the example, T will be double). > > The code (see converter.cxx) I wrote is still in early stage of > development (no check) but compiles fine on ubuntu oneiric with boost > python 1.46. I used it to create an std module. However, a simple test > (see test.py) does not work as exepted. > > Did I misunderstood something or does boost have a special treatment for > the list object which bypasses converters ? > The problem is that your "print" function takes a std::vector by reference, and you've defined an rvalue converter, which will only match value or const reference arguments. In other words, void print(std::vector const & v) {...} or void print(std::vector v) {...} should work. Everything else looks good. HTH! Jim From dave at boostpro.com Mon Apr 23 18:01:47 2012 From: dave at boostpro.com (Dave Abrahams) Date: Mon, 23 Apr 2012 12:01:47 -0400 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python References: Message-ID: on Sun Apr 22 2012, Holger Brandsmeier wrote: > Dear list, > > how is it possible to have a class in C++ that can be extended from > python and that stores a weak_ptr to itself? Easy, I think: just like any other class you wrap. Are you aware of boost::enable_shared_from_this? It does all of that internally. > The reason why I want to do this: > - using a weak_ptr to itself does not introduce a memory leak. > - from a C++-member of that class I can call other functions that > expect a shared_ptr<>, in that case I convert the weak_ptr to a > shared_ptr and all the memory management works nicely. > > The way I would suspect this to work is: > struct I { > void setThisRCP(boost::shared_ptr ptr) { > thisRCP = ptr; > } > > boost::shared_ptr getThisRCP() const { > return thisRCP.lock(); > } > > boost::weak_ptr thisRCP; > }; > > Then I export this class to C++ and in python I would do: > class IDer(I): > def __init__(self): > I.__init__(self) > self.setThisRCP(self) > > And I would suspect that I can use that class now in C++ and in > particular calling getThisRCP() from C++ returns a valid shared > pointer. However, immediately after the call of > `self.setThisRCP(self)` the weak_ptr is already invalid and getThisRCP > returns an shared pointer to Null (None in python). If you use boost::shared_ptr as the Holder for your wrapper, you'll be able to do that conversion. I see you've done that with "J" in your example, but not with "I". Why not? If you use enable_shared_from_this, the internal weak_ptr will be initialized from the first shared_ptr that is constructed to manage the object. Everything should work. -- Dave Abrahams BoostPro Computing http://www.boostpro.com From faheem at faheem.info Mon Apr 23 18:11:50 2012 From: faheem at faheem.info (Faheem Mitha) Date: Mon, 23 Apr 2012 21:41:50 +0530 (IST) Subject: [C++-sig] Boost Python exceptions cannot be pickled Message-ID: Hi, Briefly, when using the multiprocessing module, when exceptions are thrown, they need to be pickleable in order to propagate, since that is how multiprocessing passes information around. See http://stackoverflow.com/questions/8785899/hang-in-python-script-using-sqlalchemy-and-multiprocessing and Python bug http://bugs.python.org/issue1692335 for background. I've reported bugs http://bugs.python.org/issue13751 and http://www.sqlalchemy.org/trac/ticket/2371 and http://psycopg.lighthouseapp.com/projects/62710-psycopg/tickets/90-psycopg-exceptions-cannot-be-pickled and http://bugs.python.org/issue13760 in this context. I've been reporting them as I came across them. I can produce a complete example if necessary, but I think the problem is pretty obvious. Let me know whether you require followup action from me. Specifically, do you want me to report a bug? See below the traceback I just ran into. Please CC me on all replies. Thanks. Regards, Faheem ******************************************************************* Process PoolWorker-1: Traceback (most recent call last): File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap Process PoolWorker-2: Traceback (most recent call last): File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap self.run() File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python2.6/multiprocessing/pool.py", line 71, in worker self.run() File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run self._target(*self._args, **self._kwargs) File "/usr/lib/python2.6/multiprocessing/pool.py", line 71, in worker put((job, i, result)) File "/usr/lib/python2.6/multiprocessing/queues.py", line 366, in put put((job, i, result)) File "/usr/lib/python2.6/multiprocessing/queues.py", line 366, in put return send(obj) PicklingError: Can't pickle : import of module Boost.Python failed return send(obj) PicklingError: Can't pickle : import of module Boost.Python failed From brandsmeier at gmx.de Mon Apr 23 20:48:33 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Mon, 23 Apr 2012 20:48:33 +0200 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: Dear Dave, dear Jim, thanks for your help in particular to `boost::enable_shared_from_this` which I wasn't aware about in the beginning. Unfortunately your solutions did not yet work. In the meantime I figured out a different way of doing the shared pointer from this in python. Namely, to just make getThisRCP() a virtual function, add it to the Wrapper and to implement it in the python by implementing it as def getThisRCP(self): return self this simply works. As for the issue that I reported, it still persists so out of interest I did try your suggestions and here is what I found out. the difference between the lines class_("I", init<>() ) and class_, boost::noncopyable >("I", init<>() ) didn't change anything, the getThisRCP() still doesn't work. In fact I tried both variants before and send you just the first one. Can it be that specifying the holder for IWrapper does not apply to the holder for the subclass IDer from python? In fact the statement class_, boost::noncopyable >("I", init<>() ) has an issue. When I call getThisRCP() later, and the return value is not a null shared pointer, then I in fact the error TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr which is quite annoying. I also implemented Dave's suggestion with boost::enable_shared_from_this and because of the above issue I used this for the Wrapper and not the class itself (see K and KWrapper in the attachment). The behaviour of `enable_shared_from_this` is different from my initual getThisRCP() / setThisRCP() solution but still has seriour problems. Concider the code: class KDer(K): def __init__(self): K.__init__(self) k = KDer() In contrast to my initial solution the lines assert k.getThisRCP2() is not None k2 = k.getThisRCP2() now work, which is nice. Also this call works now: print k2.foo(); However, the following two lines del k print k2.foo(); give a segmentation fault. Note that the destructor for the class `K` has not been called, which would have printed a statement. The `gdb` backtrace is #0 0x00007ffff64425d7 in boost::python::objects::instance_dealloc (inst=0xe51788) at libs/python/src/object/class.cpp:335 #1 0x00007ffff7aba7f6 in subtype_dealloc (self=0xe51788) at Objects/typeobject.c:1014 #2 0x00007ffff7a72413 in instancemethod_dealloc (im=0xae0730) at Objects/classobject.c:2364 #3 0x00007ffff645387e in xdecref<_object> (p=) at ./boost/python/refcount.hpp:36 #4 ~handle (this=, __in_chrg=) at ./boost/python/handle.hpp:211 #5 boost::python::detail::wrapper_base::get_override (this=0xaec988, name=0x7fffe41de992 "foo", class_object=0x71bb10) at libs/python/src/wrapper.cpp:21 #6 0x00007fffe41d95f1 in get_override (name=, this=, name=) at /usr/include/boost/python/wrapper.hpp:29 #7 KWrapper::foo (this=0xaec980) at /home/bholger/HolgerBrandsmeier/parfem.h/python/thisRCPPy.cpp:112 [...] Any ideas? -Holger On Mon, Apr 23, 2012 at 18:01, Dave Abrahams wrote: > > on Sun Apr 22 2012, Holger Brandsmeier wrote: > >> Dear list, >> >> how is it possible to have a class in C++ that can be extended from >> python and that stores a weak_ptr to itself? > > Easy, I think: just like any other class you wrap. ?Are you aware of > boost::enable_shared_from_this? ?It does all of that internally. > >> The reason why I want to do this: >> ?- using a weak_ptr to itself does not introduce a memory leak. >> ?- from a C++-member of that class I can call other functions that >> expect a shared_ptr<>, in that case I convert the weak_ptr to a >> shared_ptr and all the memory management works nicely. >> >> The way I would suspect this to work is: >> struct I { >> ? void setThisRCP(boost::shared_ptr ptr) { >> ? ? thisRCP = ptr; >> ? } >> >> ? boost::shared_ptr getThisRCP() const { >> ? ? return thisRCP.lock(); >> ? } >> >> ? boost::weak_ptr thisRCP; >> }; >> >> Then I export this class to C++ and in python I would do: >> class IDer(I): >> ? def __init__(self): >> ? ? I.__init__(self) >> ? ? self.setThisRCP(self) >> >> And I would suspect that I can use that class now in C++ and in >> particular calling getThisRCP() from C++ returns a valid shared >> pointer. However, immediately after the call of >> `self.setThisRCP(self)` the weak_ptr is already invalid and getThisRCP >> returns an shared pointer to Null (None in python). > > If you use boost::shared_ptr as the Holder for your wrapper, you'll > be able to do that conversion. ?I see you've done that with "J" in your > example, but not with "I". ?Why not? > > If you use enable_shared_from_this, the internal weak_ptr will be > initialized from the first shared_ptr that is constructed to manage the > object. ?Everything should work. > > -- > Dave Abrahams > BoostPro Computing > http://www.boostpro.com > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig -------------- next part -------------- A non-text attachment was scrubbed... Name: test_rcp.py Type: application/octet-stream Size: 833 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: thisRCPPy.cpp Type: text/x-c++src Size: 3024 bytes Desc: not available URL: From dave at boostpro.com Mon Apr 23 22:25:32 2012 From: dave at boostpro.com (Dave Abrahams) Date: Mon, 23 Apr 2012 16:25:32 -0400 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python References: Message-ID: on Mon Apr 23 2012, Holger Brandsmeier wrote: > In fact the statement > class_, boost::noncopyable >>("I", init<>() ) > has an issue. When I call getThisRCP() later, and the return value is > not a null shared pointer, then I in fact the error > TypeError: No to_python (by-value) converter found for C++ type: > boost::shared_ptr > which is quite annoying. I also implemented Dave's suggestion with > boost::enable_shared_from_this and because of the above issue I used > this for the Wrapper and not the class itself (see K and KWrapper in > the attachment). > > The behaviour of `enable_shared_from_this` is different from my > initual getThisRCP() / setThisRCP() solution but still has seriour > problems. Concider the code: > > class KDer(K): > def __init__(self): > K.__init__(self) > > k = KDer() > > In contrast to my initial solution the lines > assert k.getThisRCP2() is not None > k2 = k.getThisRCP2() > now work, which is nice. > > Also this call works now: > print k2.foo(); > > However, the following two lines > del k > print k2.foo(); > give a segmentation fault. Note that the destructor for the class `K` > has not been called, which would have printed a statement. Please post a reduced example without any of the "J" business that illustrates exactly the problem you're having for this one particular case. If doing so doesn't immediately reveal the problem to you, I'm sure we can get to the bottom of it here. -- Dave Abrahams BoostPro Computing http://www.boostpro.com From brandsmeier at gmx.de Mon Apr 23 22:52:26 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Mon, 23 Apr 2012 22:52:26 +0200 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: Dave, Here is the reduced example with only the `boost::enable_shared_from_this` variant. The issues are all as reported before. -Holger On Mon, Apr 23, 2012 at 22:25, Dave Abrahams wrote: > > on Mon Apr 23 2012, Holger Brandsmeier wrote: > >> In fact the statement >> ? class_, boost::noncopyable >>>("I", init<>() ) >> has an issue. When I call getThisRCP() later, and the return value is >> not a null shared pointer, then I in fact the error >> TypeError: No to_python (by-value) converter found for C++ type: >> boost::shared_ptr >> which is quite annoying. I also implemented Dave's suggestion with >> boost::enable_shared_from_this and because of the above issue I used >> this for the Wrapper and not the class itself (see K and KWrapper in >> the attachment). >> >> The behaviour of `enable_shared_from_this` is different from my >> initual getThisRCP() / setThisRCP() solution but still has seriour >> problems. Concider the code: >> >> class KDer(K): >> ? def __init__(self): >> ? ? K.__init__(self) >> >> k = KDer() >> >> In contrast to my initial solution the lines >> ? assert k.getThisRCP2() is not None >> ? k2 = k.getThisRCP2() >> now work, which is nice. >> >> Also this call works now: >> ? print k2.foo(); >> >> However, the following two lines >> ? del k >> ? print k2.foo(); >> give a segmentation fault. Note that the destructor for the class `K` >> has not been called, which ?would have printed a statement. > > Please post a reduced example without any of the "J" business that > illustrates exactly the problem you're having for this one particular > case. ?If doing so doesn't immediately reveal the problem to you, I'm > sure we can get to the bottom of it here. > > > -- > Dave Abrahams > BoostPro Computing > http://www.boostpro.com > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig -------------- next part -------------- A non-text attachment was scrubbed... Name: test_rcp.py Type: application/octet-stream Size: 437 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: thisRCPPy.cpp Type: text/x-c++src Size: 1158 bytes Desc: not available URL: From talljimbo at gmail.com Tue Apr 24 05:46:30 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Mon, 23 Apr 2012 23:46:30 -0400 Subject: [C++-sig] No automatic upcasting with std::shared_ptr in function calls? In-Reply-To: References: Message-ID: <4F962216.70604@gmail.com> On 04/20/2012 03:55 AM, V?clav?milauer wrote: > Hello, > > I have a sample hierarchy of polymorphic classes (A from which B inherits). > One of them (A1, B1) is managed with boost::shared_ptr, the other one > (A2, B2) via std::shared_ptr (I defined the get_pointer template for > std::shared_ptr). > > When I call f1(boost::shared_ptr) with an object B1 from python, > it is correctly upcast to the pointer to its base class and the c++ > function is called. When I call f2(std::shared_ptr) with B2 argument > from python, no upcasting takes place and I get Boost.Python.Argument > error. > > > Where is the problem? > I'm pretty sure this is a symptom of the fact that boost::shared_ptr is handled specially by Boost.Python, and custom smart pointers (which is what std::shared_ptr is considered in this case) don't have all the same features. In particular, Boost.Python doesn't assume that custom smart pointers have implicit upcast converters, which would be needed to do what you want (note that some smart pointers, like boost::scoped_ptr, don't have implicit upcast converters). The good news is that there's an easy workaround. You just need to tell Boost.Python that the implicit conversion exists: implicitly_convertible,std::shared_ptr>(); That was enough to get your example to work for me. Jim From dave at boostpro.com Wed Apr 25 15:32:39 2012 From: dave at boostpro.com (Dave Abrahams) Date: Wed, 25 Apr 2012 09:32:39 -0400 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python References: Message-ID: I don't understand; all the enable_shared_from_this stuff is commented out. Can you please post the complete, correct example that you tried? on Mon Apr 23 2012, Holger Brandsmeier wrote: > Dave, > > Here is the reduced example with only the > `boost::enable_shared_from_this` variant. The issues are all as > reported before. > > -Holger > > On Mon, Apr 23, 2012 at 22:25, Dave Abrahams wrote: >> >> on Mon Apr 23 2012, Holger Brandsmeier wrote: >> >>> In fact the statement >>> ? class_, boost::noncopyable >>>>("I", init<>() ) >>> has an issue. When I call getThisRCP() later, and the return value is >>> not a null shared pointer, then I in fact the error >>> TypeError: No to_python (by-value) converter found for C++ type: >>> boost::shared_ptr >>> which is quite annoying. I also implemented Dave's suggestion with >>> boost::enable_shared_from_this and because of the above issue I used >>> this for the Wrapper and not the class itself (see K and KWrapper in >>> the attachment). >>> >>> The behaviour of `enable_shared_from_this` is different from my >>> initual getThisRCP() / setThisRCP() solution but still has seriour >>> problems. Concider the code: >>> >>> class KDer(K): >>> ? def __init__(self): >>> ? ? K.__init__(self) >>> >>> k = KDer() >>> >>> In contrast to my initial solution the lines >>> ? assert k.getThisRCP2() is not None >>> ? k2 = k.getThisRCP2() >>> now work, which is nice. >>> >>> Also this call works now: >>> ? print k2.foo(); >>> >>> However, the following two lines >>> ? del k >>> ? print k2.foo(); >>> give a segmentation fault. Note that the destructor for the class `K` >>> has not been called, which ?would have printed a statement. >> >> Please post a reduced example without any of the "J" business that >> illustrates exactly the problem you're having for this one particular >> case. ?If doing so doesn't immediately reveal the problem to you, I'm >> sure we can get to the bottom of it here. >> >> >> -- >> Dave Abrahams >> BoostPro Computing >> http://www.boostpro.com >> >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> http://mail.python.org/mailman/listinfo/cplusplus-sig > > from thisRCPPy import * > > print '\ntestcase for thisRCP as from python extended class (using enable_shared_from_this):' > class KDer(K): > def __init__(self): > K.__init__(self) > > k = KDer() > assert k.getThisRCP2() is not None > k2 = k.getThisRCP2() > if 1: > print k2.foo(); > del k > print 'with the `del k` statement the following statement will crash the program:'; > print k2.foo(); > print 'this line is never reached'; > #del k > del k2 > > > #include > #include "iostream" > #include "string" > #include "boost/weak_ptr.hpp" > #include "boost/enable_shared_from_this.hpp" > > using namespace boost::python; > using namespace std; > //using Teuchos::RCP; > > struct K > // : public boost::enable_shared_from_this > { > virtual int foo() = 0; > > virtual ~K() { > std::cout << "destructor for K called ..." << std::endl; > } > > /*boost::shared_ptr getThisRCP() { > return shared_from_this(); > }*/ > }; > > struct KWrapper : public K, public boost::python::wrapper, > public boost::enable_shared_from_this > { > > KWrapper() { > > } > > virtual int foo() { > if( override f = this->get_override("foo") ) { > return f(); > } else { > return base_foo(); > } > } > > boost::shared_ptr getThisRCP2() { > return shared_from_this(); > } > > int base_foo() { > return 0; > } > }; > > BOOST_PYTHON_MODULE(thisRCPPy) > { > { > typedef K ClassT; > class_, boost::noncopyable >("K", init<>() ) > //.def("getThisRCP", &ClassT::getThisRCP) > .def("getThisRCP2", &KWrapper::getThisRCP2) > .def("foo", &ClassT::foo) > ; > } > } > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig -- Dave Abrahams BoostPro Computing http://www.boostpro.com From brandsmeier at gmx.de Wed Apr 25 15:59:28 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Wed, 25 Apr 2012 15:59:28 +0200 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: Not all of it is commented out, it is enabled for the wrapper. You can try to enable it for the class itself, but then I get a different error, namely: > In fact the statement > class_, boost::noncopyable>("I", init<>() ) > has an issue. When I call getThisRCP() later, and the return value is > not a null shared pointer, then I in fact the error > TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr > which is quite annoying. I also implemented Dave's suggestion with > boost::enable_shared_from_this and because of the above issue I used > this for the Wrapper and not the class itself (see K and KWrapper in > the attachment). -Holger On Wed, Apr 25, 2012 at 15:32, Dave Abrahams wrote: > > I don't understand; all the enable_shared_from_this stuff is commented > out. ?Can you please post the complete, correct example that you tried? > > on Mon Apr 23 2012, Holger Brandsmeier wrote: > >> Dave, >> >> Here is the reduced example with only the >> `boost::enable_shared_from_this` variant. The issues are all as >> reported before. >> >> -Holger >> >> On Mon, Apr 23, 2012 at 22:25, Dave Abrahams wrote: >>> >>> on Mon Apr 23 2012, Holger Brandsmeier wrote: >>> >>>> In fact the statement >>>> ? class_, boost::noncopyable >>>>>("I", init<>() ) >>>> has an issue. When I call getThisRCP() later, and the return value is >>>> not a null shared pointer, then I in fact the error >>>> TypeError: No to_python (by-value) converter found for C++ type: >>>> boost::shared_ptr >>>> which is quite annoying. I also implemented Dave's suggestion with >>>> boost::enable_shared_from_this and because of the above issue I used >>>> this for the Wrapper and not the class itself (see K and KWrapper in >>>> the attachment). >>>> >>>> The behaviour of `enable_shared_from_this` is different from my >>>> initual getThisRCP() / setThisRCP() solution but still has seriour >>>> problems. Concider the code: >>>> >>>> class KDer(K): >>>> ? def __init__(self): >>>> ? ? K.__init__(self) >>>> >>>> k = KDer() >>>> >>>> In contrast to my initial solution the lines >>>> ? assert k.getThisRCP2() is not None >>>> ? k2 = k.getThisRCP2() >>>> now work, which is nice. >>>> >>>> Also this call works now: >>>> ? print k2.foo(); >>>> >>>> However, the following two lines >>>> ? del k >>>> ? print k2.foo(); >>>> give a segmentation fault. Note that the destructor for the class `K` >>>> has not been called, which ?would have printed a statement. >>> >>> Please post a reduced example without any of the "J" business that >>> illustrates exactly the problem you're having for this one particular >>> case. ?If doing so doesn't immediately reveal the problem to you, I'm >>> sure we can get to the bottom of it here. >>> >>> >>> -- >>> Dave Abrahams >>> BoostPro Computing >>> http://www.boostpro.com >>> >>> _______________________________________________ >>> Cplusplus-sig mailing list >>> Cplusplus-sig at python.org >>> http://mail.python.org/mailman/listinfo/cplusplus-sig >> >> from thisRCPPy import * >> >> print '\ntestcase for thisRCP as from python extended class (using enable_shared_from_this):' >> class KDer(K): >> ? def __init__(self): >> ? ? K.__init__(self) >> >> k = KDer() >> assert k.getThisRCP2() is not None >> k2 = k.getThisRCP2() >> if 1: >> ? print k2.foo(); >> ? del k >> ? print 'with the `del k` statement the following statement will crash the program:'; >> ? print k2.foo(); >> ? print 'this line is never reached'; >> ? #del k >> ? del k2 >> >> >> #include >> #include "iostream" >> #include "string" >> #include "boost/weak_ptr.hpp" >> #include "boost/enable_shared_from_this.hpp" >> >> using namespace boost::python; >> using namespace std; >> //using Teuchos::RCP; >> >> struct K >> // : public boost::enable_shared_from_this >> { >> ? virtual int foo() = 0; >> >> ? virtual ~K() { >> ? ? std::cout << "destructor for K called ..." << std::endl; >> ? } >> >> ? /*boost::shared_ptr getThisRCP() { >> ? ? return shared_from_this(); >> ? }*/ >> }; >> >> struct KWrapper : public K, public boost::python::wrapper, >> ? public boost::enable_shared_from_this >> { >> >> ? KWrapper() { >> >> ? } >> >> ? virtual int foo() { >> ? ? if( override f = this->get_override("foo") ) { >> ? ? ? return f(); >> ? ? } else { >> ? ? ? return base_foo(); >> ? ? } >> ? } >> >> ? boost::shared_ptr getThisRCP2() { >> ? ? return shared_from_this(); >> ? } >> >> ? int base_foo() { >> ? ? return 0; >> ? } >> }; >> >> BOOST_PYTHON_MODULE(thisRCPPy) >> { >> ? { >> ? ? typedef K ClassT; >> ? ? class_, boost::noncopyable >("K", init<>() ) >> ? ? ? //.def("getThisRCP", &ClassT::getThisRCP) >> ? ? ? .def("getThisRCP2", &KWrapper::getThisRCP2) >> ? ? ? .def("foo", &ClassT::foo) >> ? ? ? ; >> ? } >> } >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> http://mail.python.org/mailman/listinfo/cplusplus-sig > > -- > Dave Abrahams > BoostPro Computing > http://www.boostpro.com > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From bcatanzaro at acm.org Thu Apr 26 18:43:55 2012 From: bcatanzaro at acm.org (Bryan Catanzaro) Date: Thu, 26 Apr 2012 16:43:55 +0000 (UTC) Subject: [C++-sig] =?utf-8?q?weak=5Fptr_to_this_in_C++_classes_extended_fr?= =?utf-8?q?om_python?= References: Message-ID: Holger Brandsmeier gmx.de> writes: > > Dear list, > > how is it possible to have a class in C++ that can be extended from > python and that stores a weak_ptr to itself? Have you tried using boost::enable_shared_from_this? The following example code seems to do what you want. ------------ foo.cpp ------------ #include #include #include #include //Inheriting boost::enable_shared_from_this adds a weak_ptr to the object //That gets automatically initialized when you construct a shared_ptr //holding the object. class A : public boost::enable_shared_from_this { static int counter; public: int id; A() { id = counter++; std::cout << "Constructing A[" << id << "]" << std::endl; } ~A() { std::cout << "Destructing A[" << id << "]" << std::endl; } //This function allows us to get a shared_ptr holding the object boost::shared_ptr ptr() { return shared_from_this(); } }; int A::counter = 0; using namespace boost::python; class B { boost::shared_ptr m_a; static int counter; public: int id; //Notice that B accepts an A object directly //And asks it for the shared_ptr which holds it. B(A& a) : m_a(a.ptr()) { id = counter++; std::cout << "Constructing B[" << id << "]"; std::cout << ", which holds A[" << m_a->id << "]" << std::endl; } ~B() { std::cout << "Destructing B[" << id << "]"; std::cout << ", which holds A[" << m_a->id << "]" << std::endl; } }; int B::counter = 0; BOOST_PYTHON_MODULE(foo) { class_ >("A", init<>()); class_("B", init()); } ----------------------------------- ------------ test.py ------------ import foo class ExtendedA(foo.A): def special(self): return "successfully extended foo.A" a0 = foo.A() a = ExtendedA() print a.special() print "an ExtendedA object is a foo.A object: %s" % isinstance(a, foo.A) b = foo.B(a) ----------------------------------- On my system the output is: Constructing A[0] Constructing A[1] successfully extended foo.A an ExtendedA object is a foo.A object: True Constructing B[0], which holds A[1] Destructing B[0], which holds A[1] Destructing A[1] Destructing A[0] From brandsmeier at gmx.de Thu Apr 26 20:49:26 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Thu, 26 Apr 2012 20:49:26 +0200 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: Bryan, my problems happen as soon as I need to use wrappers. I really need the class that I extend in python to implement some pure virtual function in the C++ class. I extended your code and refined what is going wrong. I tried several Variants with different errors, I used #defines to show you all 4 versions, next to each Variant I put a C++ comment of what is going wrong. So here it is: ------------ foo.cpp ------------ #include #include #include #include using namespace boost::python; class A : public boost::enable_shared_from_this { static int counter; public: int id; A() { id = counter++; std::cout << "Constructing A[" << id << "]" << std::endl; } ~A() { std::cout << "Destructing A[" << id << "]" << std::endl; } boost::shared_ptr ptr() { return shared_from_this(); } #define VARIANT0 #ifdef VARIANT0 // this variant works nicely with VARIANT1 below (compiles and // no error for `aa = a.ptr()`), but it produces wrong results, // i.e. `77` is returned for `aa.foo()` although it should have // been `33`. virtual int foo() { return 77; } #else virtual int foo() = 0; #endif }; struct AWrapper : public A, public boost::python::wrapper { virtual int foo() { if( override f = this->get_override("foo") ) { return f(); } else { return 42; } } }; int A::counter = 0; using namespace boost::python; BOOST_PYTHON_MODULE(foo) { #define VARIANT1 //#define VARIANT2 //#define VARIANT3 #ifdef VARIANT1 // The following line doesn't compites it gives the error: // error: cannot allocate an object of abstract type ?A? class_, boost::noncopyable >("A", init<>()) #endif #ifdef VARIANT2 // the following compiles, but produces an error in python, when executing // aa = a.ptr(); // RuntimeError: tr1::bad_weak_ptr class_("A", init<>()) #endif #ifdef VARIANT3 // the following compiles, but produces an error in python, when executing // aa = a.ptr(); // TypeError: No to_python (by-value) converter found for C++ type: boost::shared_ptr class_, boost::noncopyable >("A", init<>()) #endif .def("ptr", &A::ptr) .def("foo", &A::foo) ; } ----------------------------------- ------------ ?foo.py ?------------ import foo class ExtendedA(foo.A): def foo(self): return 33; a0 = foo.A() a = ExtendedA() aa = a.ptr(); print a.foo() del a print aa.foo() ----------------------------------- Do you have any suggestion how to get this working? -Holger On Thu, Apr 26, 2012 at 18:43, Bryan Catanzaro wrote: > Holger Brandsmeier gmx.de> writes: > >> >> Dear list, >> >> how is it possible to have a class in C++ that can be extended from >> python and that stores a weak_ptr to itself? > > > Have you tried using boost::enable_shared_from_this? ?The following example code > seems to do what you want. From bcatanzaro at acm.org Fri Apr 27 08:22:44 2012 From: bcatanzaro at acm.org (Bryan Catanzaro) Date: Thu, 26 Apr 2012 23:22:44 -0700 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: I think the problem is that aa is no longer an ExtendedA object, because when you call ptr() it returns a pointer to the base C++ A class, not the derived class. I think at this point it's probably best to reconsider the problem and come up with a simpler solution. Why do you want to expose the ptr method to Python anyway? - bryan On Thu, Apr 26, 2012 at 11:49 AM, Holger Brandsmeier wrote: > Bryan, > > my problems happen as soon as I need to use wrappers. I really need > the class that I extend in python to implement some pure virtual > function in the C++ class. I extended your code and refined what is > going wrong. I tried several Variants with different errors, I used > #defines to show you all 4 versions, next to each Variant I put a C++ > comment of what is going wrong. > > So here it is: > > ------------ ?foo.cpp ?------------ > #include > #include > #include > #include > > using namespace boost::python; > > class A > ? : public boost::enable_shared_from_this { > ? static int counter; > public: > ? int id; > ? A() { > ? ? ? id = counter++; > ? ? ? std::cout << "Constructing A[" << id << "]" << std::endl; > ? } > ? ~A() { > ? ? ? std::cout << "Destructing A[" << id << "]" << std::endl; > ? } > ? boost::shared_ptr ptr() { > ? ? ? return shared_from_this(); > ? } > #define VARIANT0 > #ifdef VARIANT0 > ? // this variant works nicely with VARIANT1 below (compiles and > ? // no error for `aa = a.ptr()`), but it produces wrong results, > ? // i.e. `77` is returned for `aa.foo()` although it should have > ? // been `33`. > ? virtual int foo() { > ? ? ?return 77; > ? } > #else > ? virtual int foo() = 0; > #endif > }; > > struct AWrapper : public A, public boost::python::wrapper { > ?virtual int foo() { > ? ?if( override f = this->get_override("foo") ) { > ? ? ?return f(); > ? ?} else { > ? ? ?return 42; > ? ?} > ?} > }; > > int A::counter = 0; > > using namespace boost::python; > > > BOOST_PYTHON_MODULE(foo) { > #define VARIANT1 > //#define VARIANT2 > //#define VARIANT3 > > #ifdef VARIANT1 > ? // The following line doesn't compites it gives the error: > ? // error: cannot allocate an object of abstract type ?A? > ? class_, boost::noncopyable >("A", init<>()) > #endif > #ifdef VARIANT2 > ?// the following compiles, but produces an error in python, when executing > ?// aa = a.ptr(); > ?// RuntimeError: tr1::bad_weak_ptr > ? class_("A", init<>()) > #endif > #ifdef VARIANT3 > ? // the following compiles, but produces an error in python, when executing > ? // aa = a.ptr(); > ? // TypeError: No to_python (by-value) converter found for C++ type: > boost::shared_ptr > ? class_, boost::noncopyable >>("A", init<>()) > #endif > ? ? .def("ptr", &A::ptr) > ? ? .def("foo", &A::foo) > ? ? ; > } > ----------------------------------- > > ------------ ?foo.py ?------------ > import foo > > class ExtendedA(foo.A): > ? def foo(self): > ? ? return 33; > > a0 = foo.A() > a = ExtendedA() > aa = a.ptr(); > print a.foo() > del a > print aa.foo() > ----------------------------------- > > Do you have any suggestion how to get this working? > -Holger > > On Thu, Apr 26, 2012 at 18:43, Bryan Catanzaro wrote: >> Holger Brandsmeier gmx.de> writes: >> >>> >>> Dear list, >>> >>> how is it possible to have a class in C++ that can be extended from >>> python and that stores a weak_ptr to itself? >> >> >> Have you tried using boost::enable_shared_from_this? ?The following example code >> seems to do what you want. > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From brandsmeier at gmx.de Fri Apr 27 14:00:29 2012 From: brandsmeier at gmx.de (Holger Brandsmeier) Date: Fri, 27 Apr 2012 14:00:29 +0200 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python In-Reply-To: References: Message-ID: On Fri, Apr 27, 2012 at 08:22, Bryan Catanzaro wrote: > I think the problem is that aa is no longer an ExtendedA object, > because when you call ptr() it returns a pointer to the base C++ A > class, not the derived class. I think you got something confused. A boost::shared_pointer can very well be any pointer to any derived class, no copy should be created. I can still call virtual functions from `A` and should get the result from the implementation of `ExtendedA`. > I think at this point it's probably best to reconsider the problem and > come up with a simpler solution. ?Why do you want to expose the ptr > method to Python anyway? I don't plan to call `ptr()` from python, but I will call the same function from C++ and and at some point the result that C++ produced can find its way back to python. I did find a different solution to this problem: On Mon, Apr 23, 2012 at 20:48, Holger Brandsmeier wrote: > In the meantime I figured out a different way of doing the shared > pointer from this in python. Namely, to just make getThisRCP() a > virtual function, add it to the Wrapper and to implement it in the > python by implementing it as but I still expect the above mentioned approch with `boost::enable_shared_from_this` _should_ have worked with boost python. I seem to run into an issue that even Dave can not explain (well lets wait for his reply). Moreover note that in boost::python usually if C++ returns a `shared_ptr` which has previously been created as an instance of `ExtendedA` inside python, than this class is available as `ExtendedA`. There is some magic with custom deleters that usually makes you able to treat that class as instance of `ExtendedA`. This magic will also stop working when you use `boost::enable_shared_from_this`. With that aspect I can live, though. -Holger > On Thu, Apr 26, 2012 at 11:49 AM, Holger Brandsmeier wrote: >> Bryan, >> >> my problems happen as soon as I need to use wrappers. I really need >> the class that I extend in python to implement some pure virtual >> function in the C++ class. I extended your code and refined what is >> going wrong. I tried several Variants with different errors, I used >> #defines to show you all 4 versions, next to each Variant I put a C++ >> comment of what is going wrong. >> >> So here it is: >> >> ------------ ?foo.cpp ?------------ >> #include >> #include >> #include >> #include >> >> using namespace boost::python; >> >> class A >> ? : public boost::enable_shared_from_this { >> ? static int counter; >> public: >> ? int id; >> ? A() { >> ? ? ? id = counter++; >> ? ? ? std::cout << "Constructing A[" << id << "]" << std::endl; >> ? } >> ? ~A() { >> ? ? ? std::cout << "Destructing A[" << id << "]" << std::endl; >> ? } >> ? boost::shared_ptr ptr() { >> ? ? ? return shared_from_this(); >> ? } >> #define VARIANT0 >> #ifdef VARIANT0 >> ? // this variant works nicely with VARIANT1 below (compiles and >> ? // no error for `aa = a.ptr()`), but it produces wrong results, >> ? // i.e. `77` is returned for `aa.foo()` although it should have >> ? // been `33`. >> ? virtual int foo() { >> ? ? ?return 77; >> ? } >> #else >> ? virtual int foo() = 0; >> #endif >> }; >> >> struct AWrapper : public A, public boost::python::wrapper { >> ?virtual int foo() { >> ? ?if( override f = this->get_override("foo") ) { >> ? ? ?return f(); >> ? ?} else { >> ? ? ?return 42; >> ? ?} >> ?} >> }; >> >> int A::counter = 0; >> >> using namespace boost::python; >> >> >> BOOST_PYTHON_MODULE(foo) { >> #define VARIANT1 >> //#define VARIANT2 >> //#define VARIANT3 >> >> #ifdef VARIANT1 >> ? // The following line doesn't compites it gives the error: >> ? // error: cannot allocate an object of abstract type ?A? >> ? class_, boost::noncopyable >("A", init<>()) >> #endif >> #ifdef VARIANT2 >> ?// the following compiles, but produces an error in python, when executing >> ?// aa = a.ptr(); >> ?// RuntimeError: tr1::bad_weak_ptr >> ? class_("A", init<>()) >> #endif >> #ifdef VARIANT3 >> ? // the following compiles, but produces an error in python, when executing >> ? // aa = a.ptr(); >> ? // TypeError: No to_python (by-value) converter found for C++ type: >> boost::shared_ptr >> ? class_, boost::noncopyable >>>("A", init<>()) >> #endif >> ? ? .def("ptr", &A::ptr) >> ? ? .def("foo", &A::foo) >> ? ? ; >> } >> ----------------------------------- >> >> ------------ ?foo.py ?------------ >> import foo >> >> class ExtendedA(foo.A): >> ? def foo(self): >> ? ? return 33; >> >> a0 = foo.A() >> a = ExtendedA() >> aa = a.ptr(); >> print a.foo() >> del a >> print aa.foo() >> ----------------------------------- >> >> Do you have any suggestion how to get this working? >> -Holger >> >> On Thu, Apr 26, 2012 at 18:43, Bryan Catanzaro wrote: >>> Holger Brandsmeier gmx.de> writes: >>> >>>> >>>> Dear list, >>>> >>>> how is it possible to have a class in C++ that can be extended from >>>> python and that stores a weak_ptr to itself? >>> >>> >>> Have you tried using boost::enable_shared_from_this? ?The following example code >>> seems to do what you want. >> _______________________________________________ >> Cplusplus-sig mailing list >> Cplusplus-sig at python.org >> http://mail.python.org/mailman/listinfo/cplusplus-sig > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig From spartan811 at hotmail.com Fri Apr 27 14:07:42 2012 From: spartan811 at hotmail.com (Yoann Chaumy) Date: Fri, 27 Apr 2012 14:07:42 +0200 Subject: [C++-sig] =?windows-1256?q?Passing_C++_object_to_script_Python=FE?= Message-ID: Hi, I have created a simple C++ class, and can successfully use in my python scripts. But my aim is to create a C++ instance, and pass it to my python script. The script will modify the instance and return it to the C++ application example : //---------------- example.h ---------------- #include #include class Personage { private: std::string m_name; int m_power; public: Personage(std::string name, int power); void setPower(); }; //---------------- example.cpp ---------------- #include "example.h" #include using namespace std;Personage::Personage(string name, int power) { m_name = name; m_power = power; } void Personage::setPower(int power) { m_power = power; } so, what should I do in the main to send an instance Personage to the script Python ? Any help would be appreciated -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan at seefeld.name Fri Apr 27 14:41:57 2012 From: stefan at seefeld.name (Stefan Seefeld) Date: Fri, 27 Apr 2012 08:41:57 -0400 Subject: [C++-sig] =?utf-8?q?Passing_C++_object_to_script_Python=E2=80=8F?= In-Reply-To: References: Message-ID: <4F9A9415.9020500@seefeld.name> On 04/27/2012 08:07 AM, Yoann Chaumy wrote: > > so, what should I do in the main to send an instance Personage to the > script Python ? Something like the following (assumes the Python interpreter is already properly initialized): void call_script(std::string const &script, Personage &p) { namespace bpl = boost::python; bpl::dict global; global["personage"] = p; // inject 'p' into script's environment bpl::exec_file(script.c_str(), global); // run it } HTH, Stefan -- ...ich hab' noch einen Koffer in Berlin... From dave at boostpro.com Fri Apr 27 15:49:39 2012 From: dave at boostpro.com (Dave Abrahams) Date: Fri, 27 Apr 2012 09:49:39 -0400 Subject: [C++-sig] weak_ptr to this in C++ classes extended from python References: Message-ID: on Fri Apr 27 2012, Holger Brandsmeier wrote: > On Mon, Apr 23, 2012 at 20:48, Holger Brandsmeier wrote: >> In the meantime I figured out a different way of doing the shared >> pointer from this in python. Namely, to just make getThisRCP() a >> virtual function, add it to the Wrapper and to implement it in the >> python by implementing it as > > but I still expect the above mentioned approch with > `boost::enable_shared_from_this` _should_ have worked with boost > python. I seem to run into an issue that even Dave can not explain > (well lets wait for his reply). Unfortunately I don't have the time to do the analysis right now, but I agree with you that it should have worked. -- Dave Abrahams BoostPro Computing http://www.boostpro.com From sybren at stuvel.eu Fri Apr 27 16:38:19 2012 From: sybren at stuvel.eu (=?UTF-8?Q?Sybren_A=2E_St=C3=BCvel?=) Date: Fri, 27 Apr 2012 16:38:19 +0200 Subject: [C++-sig] Boost::Python: inheritance + optional parameters Message-ID: Dear list, This is my first post here, so I'll briefly introduce myself. My name is Sybren and I'm a PhD student at the Utrecht University. We use Boost a lot in our C++-based framework, and naturally we use Boost::Python to create our Python bindings. I want to combine two "features" that are documented well separately, however so far I haven't been able to combine them. What I want to do is have a class in C++ with virtual methods and override them in a Python subclass, AND have those virtual methods use parameters with default values. In short, I want to wrap a class like this: class ExampleClass { public: virtual std::string override_me(int x, int y=0, bool z=false) { std::stringstream msg; msg << "(x=" << x << ", y=" << y << ", z=" << z << ", base implementation"; return msg.str(); } }; And be able to produce a subclass in Python like this: from cpp_module import ExampleClass class Subclass(ExampleClass): def override_me(self, *args): return ExampleClass.override_me(self, *args) + " has been overridden" Of course all in such a way that when I pass a Subclass instance to an ExampleClass parameter of C++ code, and that C++ code calls instance.override_me(1, 2), it returns "x=1, y=2, z=false, base implementation has been overridden". I can't seem to find any documentation about this, and what I find on this mailing list was posted several years ago and involves manually creating as many methods as there are optional parameters. I hope that in recent versions of Boost (I'm using 1.48 but have no problem upgrading to the latest release) there is a more useful technique. With kind regards, -- Sybren A. St?vel http://stuvel.eu/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From talljimbo at gmail.com Fri Apr 27 17:17:17 2012 From: talljimbo at gmail.com (Jim Bosch) Date: Fri, 27 Apr 2012 11:17:17 -0400 Subject: [C++-sig] Boost::Python: inheritance + optional parameters In-Reply-To: References: Message-ID: <4F9AB87D.7070404@gmail.com> On 04/27/2012 10:38 AM, Sybren A. St?vel wrote: > Dear list, > > This is my first post here, so I'll briefly introduce myself. My name is > Sybren and I'm a PhD student at the Utrecht University. We use Boost a lot > in our C++-based framework, and naturally we use Boost::Python to create > our Python bindings. I want to combine two "features" that are documented > well separately, however so far I haven't been able to combine them. What I > want to do is have a class in C++ with virtual methods and override them in > a Python subclass, AND have those virtual methods use parameters with > default values. In short, I want to wrap a class like this: > > class ExampleClass { > public: > virtual std::string override_me(int x, int y=0, bool z=false) { > std::stringstream msg; > msg<< "(x="<< x<< ", y="<< y<< ", z="<< z<< ", base > implementation"; > return msg.str(); > } > }; > > And be able to produce a subclass in Python like this: > > from cpp_module import ExampleClass > class Subclass(ExampleClass): > def override_me(self, *args): > return ExampleClass.override_me(self, *args) + " has been > overridden" > > Of course all in such a way that when I pass a Subclass instance to an > ExampleClass parameter of C++ code, and that C++ code calls > instance.override_me(1, 2), it returns "x=1, y=2, z=false, base > implementation has been overridden". > > I can't seem to find any documentation about this, and what I find on this > mailing list was posted several years ago and involves manually creating as > many methods as there are optional parameters. I hope that in recent > versions of Boost (I'm using 1.48 but have no problem upgrading to the > latest release) there is a more useful technique. > Have you tried using the keyword argument approach to handling default arguments? More precisely, something like this should work, I think: def("override", func, (arg("x"), arg("y")=0, arg("z")=false)) (where func is the usual wrapper override function). The disadvantage is that you have to repeat the default arguments in the wrapper code, but the advantage is that from Python you can use keyword arguments in their full glory and you don't have to worry about wrapping multiple C++ overloads. Jim From spartan811 at hotmail.com Mon Apr 30 09:43:44 2012 From: spartan811 at hotmail.com (Yoann Chaumy) Date: Mon, 30 Apr 2012 09:43:44 +0200 Subject: [C++-sig] =?windows-1256?q?Passing_C++_object_to_script_Python=FE?= In-Reply-To: <4F9A9415.9020500@seefeld.name> References: , <4F9A9415.9020500@seefeld.name> Message-ID: Hi, thank you Stefan, but a have buliding error : LINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-1_48.lib' my first C++ program to execute my Python script was : // ------------ main.cpp ------------ #include #include #include using namespace std;int main() { int fin; //Test d'existance du fichier ifstream fichier("personnage.py"); if (fichier.fail()) { cout << "Fichier de script introuvable : " << "personnage.py" <<"\n"; return 0; } // open python script FILE* pyFile = fopen("personnage.py", "r"); Py_Initialize(); // Execute le script string exec ( "execfile(r\"" ); // note r for raw Python string. exec += "personnage.py" ; exec += "\")" ; PyRun_SimpleString( (char*) exec.c_str() ); cin >> fin; Py_Finalize(); return 0; } // ----------------------------------------- but now a have a building error with this code : // -------------- new main ------------- #include #include #include #include "../Boost_Python/personnage.h"#include #include #include using namespace std; void call_script(std::string const &script, Personnage &p) { namespace bpl = boost::python; bpl::dict global; global["personnage"] = p; // inject 'p' into script's environment bpl::exec_file(script.c_str(), global); // run it } int main() { int fin; //Test d'existance du fichier ifstream fichier("personnage.py"); if (fichier.fail()) { cout << "Fichier de script introuvable : " << "personnage.py" <<"\n"; return 0; } // Ouvre le script python a executer FILE* pyFile = fopen("personnage.py", "r"); Personnage p("toto", 500); Py_Initialize(); call_script("personnage.py", p); cin >> fin; Py_Finalize(); return 0; }My error is : LINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-1_48.lib'I using VS2010 and have add C:\boost_1_48_0\stage\lib\boost_python-vc100-mt-1_48.lib to the additionnal Library Directories -------------- next part -------------- An HTML attachment was scrubbed... URL: From wmamrak at gmail.com Mon Apr 30 13:05:50 2012 From: wmamrak at gmail.com (Wojciech Mamrak) Date: Mon, 30 Apr 2012 13:05:50 +0200 Subject: [C++-sig] held type and implicitly_convertible Message-ID: Hello list, correct me if I am wrong, but based on what I have found in the docs, SO and few other places, when creating an object in Python and passing it to a wrapped C++ function which expects a pointer and which takes the ownership of that pointer, one should: * use auto_ptr as held type when wrapping types being passed to that function, * create a wrapper function expecting auto_ptr which calls original function and releases the auto_ptr. Additionally, if polymorphic types are to be passed, then implicitly_convertible should be used to avoid writing multiple wrapper functions for each derived type. My question is: what happens if held type of my class is auto_ptr, and the (original) function expects boost::shared_ptr? Does BP register a converter for these types automatically, since implicitly_convertible is not needed at all this time? Does it call shared_ptr's ctor with auto_ptr as its parameter (which calls auto_ptr's release method, causing a wrapper function to be unneeded)? Or maybe such mixing of smart pointers should be completely avoided? Thanks for help, regards From ehsanpii at gmail.com Mon Apr 30 20:11:11 2012 From: ehsanpii at gmail.com (Ehsan Pi) Date: Mon, 30 Apr 2012 14:11:11 -0400 Subject: [C++-sig] Wrapping and Passing HWND with Boost.Python Message-ID: Hello, I've created a Boost.Python wrapper (using Py++) for a C++ legacy class that takes a HWND window handle in its constructor. However, after exporting the module to python when I try to use it, I get a type mismatch error. -------------------------- Here is the C++ class I'm wrapping: // File Foo.hpp // #include "Windows.h" class Foo { public: Foo( const HWND window ){} virtual ~Foo(){} virtual int Bar( int num ) { return num; } }; -------------------------- The Py++ output: INFO Parsing source file "foo.hpp" ... INFO gccxml cmd: ""c:\Program Files (x86)\gccxml 0.9\bin\gccxml.exe" -I"." "foo.hpp" -fxml="d:\temp\tmpdng3ts.xml"" INFO GCCXML version - 0.9( 1.127 ) INFO: file "generated_wrapper.cpp" - updated( 0.001607 seconds ) -------------------------- The generated wrapper: #include "boost/python.hpp" #include "foo.hpp" namespace bp = boost::python; struct Foo_wrapper : Foo, bp::wrapper< Foo > { Foo_wrapper(::HWND const window ) : Foo( window ) , bp::wrapper< Foo >(){ // constructor } virtual int Bar( int num ) { if( bp::override func_Bar = this->get_override( "Bar" ) ) return func_Bar( num ); else{ return this->Foo::Bar( num ); } } int default_Bar( int num ) { return Foo::Bar( num ); } }; BOOST_PYTHON_MODULE(MyWrapper){ { //::Foo typedef bp::class_< Foo_wrapper > Foo_exposer_t; Foo_exposer_t Foo_exposer = Foo_exposer_t( "Foo", bp::init< HWND__ *>(( bp::arg("window") )) ); bp::scope Foo_scope( Foo_exposer ); bp::implicitly_convertible< const HWND, Foo >(); { //::Foo::Bar typedef int ( ::Foo::*Bar_function_type )( int ) ; typedef int ( Foo_wrapper::*default_Bar_function_type )( int ) ; Foo_exposer.def( "Bar" , Bar_function_type(&::Foo::Bar) , default_Bar_function_type(&Foo_wrapper::default_Bar) , ( bp::arg("num") ) ); } } } -------------------------- In python I get the not-match error: >>> import MyWrapper >>> import win32gui >>> hwnd = win32gui.GetDesktopWindow() >>> foo = MyWrapper.Foo(hwnd) Traceback (most recent call last): File "", line 1, in Boost.Python.ArgumentError: Python argument types in Foo.__init__(Foo, int) did not match C++ signature: __init__(struct _object *, struct HWND__ * window) >>> How can I correct this problem to be able to pass a window's handle (from win32gui) in Python to C++ class, and interact with it? Environment: Visual Studio 2008, Boost 1.44, gcc-xml 0.9.0, py++ 1.0.0, pygccxml 1.1.0 -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Mon Apr 30 20:46:40 2012 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Mon, 30 Apr 2012 21:46:40 +0300 Subject: [C++-sig] Wrapping and Passing HWND with Boost.Python In-Reply-To: References: Message-ID: On Mon, Apr 30, 2012 at 9:11 PM, Ehsan Pi wrote: > In python I get the not-match error: > > ? ? >>> import MyWrapper > ? ? >>> import win32gui > ? ? >>> hwnd = win32gui.GetDesktopWindow() > ? ? >>> foo = MyWrapper.Foo(hwnd) > ? ? Traceback (most recent call last): > ? ? ? File "", line 1, in > ? ? Boost.Python.ArgumentError: Python argument types in > ? ? ? ? Foo.__init__(Foo, int) > ? ? did not match C++ signature: > ? ? ? ? __init__(struct _object *, struct HWND__ * window) > ? ? >>> > > How can I correct this problem to be able to pass a window's handle (from > win32gui) in Python to C++ class, and interact with it? I think the error is pretty clear: the exported constructor expects a pointer to some struct(?) HWND__, while, win32gui returns the handle as integer. You will have to find some way to associate handle as integer with handle as HWND__. Once you find it, you can use "make_constructor" functionality, which is also supported by py++. HTH. From ehsanpii at gmail.com Mon Apr 30 20:54:04 2012 From: ehsanpii at gmail.com (Ehsan Pi) Date: Mon, 30 Apr 2012 14:54:04 -0400 Subject: [C++-sig] Wrapping and Passing HWND with Boost.Python In-Reply-To: References: Message-ID: Thanks Roman for your quick reply, That's what confuses me. HWND is essentially a pointer to an int to hold the window handle. How can to convert them to each other? Ehsan On Mon, Apr 30, 2012 at 2:46 PM, Roman Yakovenko wrote: > On Mon, Apr 30, 2012 at 9:11 PM, Ehsan Pi wrote: > > In python I get the not-match error: > > > > >>> import MyWrapper > > >>> import win32gui > > >>> hwnd = win32gui.GetDesktopWindow() > > >>> foo = MyWrapper.Foo(hwnd) > > Traceback (most recent call last): > > File "", line 1, in > > Boost.Python.ArgumentError: Python argument types in > > Foo.__init__(Foo, int) > > did not match C++ signature: > > __init__(struct _object *, struct HWND__ * window) > > >>> > > > > How can I correct this problem to be able to pass a window's handle (from > > win32gui) in Python to C++ class, and interact with it? > > I think the error is pretty clear: the exported constructor expects a > pointer to some struct(?) HWND__, while, win32gui returns the handle > as integer. You will have to find some way to associate handle as > integer with handle as HWND__. Once you find it, you can use > "make_constructor" functionality, which is also supported by py++. > > HTH. > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Mon Apr 30 21:00:25 2012 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Mon, 30 Apr 2012 22:00:25 +0300 Subject: [C++-sig] Wrapping and Passing HWND with Boost.Python In-Reply-To: References: Message-ID: On Mon, Apr 30, 2012 at 9:54 PM, Ehsan Pi wrote: > Thanks Roman for your quick reply, > > That's what confuses me. HWND is essentially a pointer to an int to hold the > window handle. How can to convert them to each other? I am not sure that you are right, but in case you are, use make_constructor and reinterpret_cast. Regards, Roman