From gleizesd at gmail.com Mon Jul 3 16:52:41 2006 From: gleizesd at gmail.com (Damien Gleizes) Date: Mon, 3 Jul 2006 14:52:41 +0000 (UTC) Subject: [C++-sig] Restarting the python interpreter Message-ID: Hello, I am having a little problem with my embedded python interpreter. I have an interface button wich should restart the interpreter but it has a strange behavior. To reset the interpreter, I was calling my EndPython function, and then the StartPython function which are like this: EndPython() { Py_Finalize(); } StartPython() { Py_Initialize(); PyObject *pMainModule = PyImport_AddModule( "__main__" ); m_Dictionary = PyModule_GetDict( pMainModule ); PyDict_SetItemString( m_Dictionary, "__builtins__", PyEval_GetBuiltins() ); StartBindingModule(); } In the function StartBindingModule(), I just import the module generated by swig. In facts, when I restart the interpreter, the memory grows up, and my module is not correctly available. Maybe is there a way to restart the interpreter by cleaning the dictionnary? Or maybe should I Py_Decref(m_Dictionnary) but it seems to make the program crash when calling PyFinalize(). Any suggestions? Thank's DaM From mark.dufour at gmail.com Mon Jul 3 23:28:13 2006 From: mark.dufour at gmail.com (Mark Dufour) Date: Mon, 3 Jul 2006 23:28:13 +0200 Subject: [C++-sig] Shed Skin Python-to-C++ Compiler Message-ID: <8180ef690607031428l24b5bdbbse50cafb5299a81ef@mail.gmail.com> Hello all, Having just released version 0.0.11 of my optimizing Python-to-C++ compiler, I thought why not ask around here if there is any interest in helping out. For those that do not know it, Shed Skin accepts pure, but implicitly statically typed, Python programs and converts them into optimized C++ code. See this page for more information: http://mark.dufour.googlepages.com Besides being quite experimental in that the type inference is quite academic and it sometimes has non-termination issues, especially with recursive datastructures (I am quite sure both problems can be handled successfully), integration with especially the standard library is the other major problem. Shed Skin currently supports several commonly-used standard library calls, and it is often simple, but some work, to add support for other calls. For example, suppose we want to support random.random. First, a 'type model' of this function must be provided in the file 'random_.py', e.g.: def random(): return 1.0. This way, the global type analysis understands what is going on externally. Second, a C++ implementation or glue layer needs to be provided with the files 'random_.?pp'. A glue layer can use the Python C API to call the real standard library. Now, as the C API is rather cumbersome (I've added support for some Pygame functionality and it didn't really help my RSI..), I am thinking about using boost.Python to quickly add support for many standard library and other modules. Trying to use it, I get this error however: scart at akemi ~/projects/shedskin $ g++ -I/usr/include/python2.4 -lpython2.4 pb.cpp /tmp/ccqUfrVQ.o: In function `main': pb.cpp:(.text+0x151): undefined reference to `boost::python::api::object::object(boost::python::handle<_object> const&)' /tmp/ccqUfrVQ.o: In function `_object* boost::python::expect_non_null<_object>(_object*)': pb.cpp:(.gnu.linkonce.t._ZN5boost6python15expect_non_nullI7_objectEEPT_S4_+0xd): undefined reference to `boost::python::throw_error_already_set()' collect2: ld returned 1 exit status Where I'm trying to compile the simple embedding example: #include using namespace boost::python; int main() { Py_Initialize(); object main_module((handle<>(borrowed(PyImport_AddModule("__main__"))))); Py_Finalize(); } Am I missing something simple? (I am using Python-2.4.3, boost 1.33.1, GCC 3.4.6 under Gentoo Linux.) Well, in any case, I would be very interested to hear your thoughts about the approach of using boost.Python to make Shed Skin more broadly applicable. I would also be very happy to receive help in implementing several commonly used modules, such as 're' and pygame.. :-) Thanks, Mark Dufour. -- if vars: self.output('; '.join([self.type(var)+' '+name for (name,var) in vars.items()])+';') From roman.yakovenko at gmail.com Tue Jul 4 08:40:16 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Tue, 4 Jul 2006 09:40:16 +0300 Subject: [C++-sig] Shed Skin Python-to-C++ Compiler In-Reply-To: <8180ef690607031428l24b5bdbbse50cafb5299a81ef@mail.gmail.com> References: <8180ef690607031428l24b5bdbbse50cafb5299a81ef@mail.gmail.com> Message-ID: <7465b6170607032340h562058dfx6438f2cd1868a214@mail.gmail.com> On 7/4/06, Mark Dufour wrote: > Hello all, > > Having just released version 0.0.11 of my optimizing Python-to-C++ > compiler, I thought why not ask around here if there is any interest > in helping out. I think I can help you with design of code generator. I created code generator for Boost.Python library and I am very pleased with it's design. It is very powerful and simple. So if you want, we can discuss it. > > scart at akemi ~/projects/shedskin $ g++ -I/usr/include/python2.4 > -lpython2.4 pb.cpp > /tmp/ccqUfrVQ.o: In function `main': > pb.cpp:(.text+0x151): undefined reference to > `boost::python::api::object::object(boost::python::handle<_object> > const&)' > /tmp/ccqUfrVQ.o: In function `_object* > boost::python::expect_non_null<_object>(_object*)': > pb.cpp:(.gnu.linkonce.t._ZN5boost6python15expect_non_nullI7_objectEEPT_S4_+0xd): > undefined reference to `boost::python::throw_error_already_set()' > collect2: ld returned 1 exit status It seems to me that the problem is that you did not build Boost.Python right( == using bjam ). Or may be you forgot to add it to link line? > Where I'm trying to compile the simple embedding example: > > #include > using namespace boost::python; > > int main() { > Py_Initialize(); > object main_module((handle<>(borrowed(PyImport_AddModule("__main__"))))); > Py_Finalize(); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ See one of the recent threads. Py_Finalize could not be used with Boost.Python library. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From mark.dufour at gmail.com Tue Jul 4 16:19:00 2006 From: mark.dufour at gmail.com (Mark Dufour) Date: Tue, 4 Jul 2006 16:19:00 +0200 Subject: [C++-sig] Shed Skin Python-to-C++ Compiler In-Reply-To: <8180ef690607031428l24b5bdbbse50cafb5299a81ef@mail.gmail.com> References: <8180ef690607031428l24b5bdbbse50cafb5299a81ef@mail.gmail.com> Message-ID: <8180ef690607040719l300aa11bvfc9cb179e9094508@mail.gmail.com> > scart at akemi ~/projects/shedskin $ g++ -I/usr/include/python2.4 > -lpython2.4 pb.cpp d'oh, forgot to add -lboost_python.. mark. -- if vars: self.output('; '.join([self.type(var)+' '+name for (name,var) in vars.items()])+';') From dave at boost-consulting.com Tue Jul 4 21:01:17 2006 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 04 Jul 2006 15:01:17 -0400 Subject: [C++-sig] boost::python std::vector< std::string > crash References: <449AA3D1.1080805@boost-consulting.com> Message-ID: John Reid writes: > Ok this seems to be a crash in debug mode when I am picking up the > release version of boost_python.dll in my path. > > How to make boost build v1 install boost_python.dll next to my > extension? Or do I need to manually copy the correct (debug/release) > version every time I want to debug or run the release version? > > I've tried adding > > @boost/libs/build/boost_python > > to my stage target to no avail. > > I have followed the 'Creating Packages' guidelines in the 'General > Techniques' documentation but could not find any documentation on how to > set up a build environment where I can alternate between debug and > release builds easily. If you use the boost-python-runtest rule as shown in libs/python/example/Jamfile it will take care of setting up these paths for you. -- Dave Abrahams Boost Consulting www.boost-consulting.com From roman.yakovenko at gmail.com Tue Jul 4 22:20:48 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Tue, 4 Jul 2006 23:20:48 +0300 Subject: [C++-sig] boost:python::arg and default value Message-ID: <7465b6170607041320j2f745b89xff3f8d44e475b1c0@mail.gmail.com> Hi. I want to resolve the issue discussed in this thread: http://thread.gmane.org/gmane.comp.python.c++/9878/focus=9881 The short version of the discussion is: class Foo; class Foo2 { friend class Foo; Foo2(Foo *f=0); }; class Foo { Foo(Foo2 *f=0); }; It is not possible to expose both Foo and Foo2 constructors with default values, without usage of some tricks. The main problem is that, when Boost.Python initializes boost::python::arg, it requires type of default value to be registered. I had some free time and took a look on the code. I think, I understand what is going on and how to fix the situation, but still need some help here and there. I see only one possible solution - to add to Boost.Python functionality, that will allow user to control argument default value conversion time. Today, the default value converted to Python during function registration. This happens in boost::python::objects::function class constructor. Solution: 1. To add classes that will define C++ to Python convert time. struct converter_base{ virtual handle<> py_value() const = 0; //const in interface is a hack, objects::function::call member function //has const modifier }; struct default_converter : converter_base{ converts value in the constructor and saves the value in a member variable py_value returns the member variable }; struct on_first_use_converter : converter_base{ saves the C++ value as member variable py_value will convert C++ value to Python on first invocation, will save the result in member variable, after this, it will always return the member variable. }; 2. Change in keyword struct. Today keyword struct keeps function default value as instance of handle<>. This should be changed. keyword struct should keep shared_ptr to coverter_base class instance or it should keep empty shared_ptr. Thus it will be possible to control C++ to Python default value conversion time from objects::function class. 3. There are few changes, that should be done to boost::python::objects::function class. This is the place I have lack of knowledge and the code is a little bit complex and fragile. More over, every additional logic, that will be added here will downgrade performance. There are few changed that should be done to the class. 1. The class should keep all keywords, that has default value converter other than default_converter. It also should save keyword position. 2. In constructor, when we register function keyword arguments, we should skip initialization of default value, for converters other than default_converter. 3. Now, the only change left is to modify function::call method. Unfortunately I can not write the working code - lack of knowledge( or sleep ). I'll be glad, if somebody can help me here. The main problem, is that some how I should pass to the function default values and I don't exactly understand how I should do that. I attached the modified files. What do you think about those changes? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -------------- next part -------------- A non-text attachment was scrubbed... Name: args.hpp Type: text/x-c++hdr Size: 5341 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: args_fwd.hpp Type: text/x-c++hdr Size: 1290 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: default_values.hpp Type: text/x-c++hdr Size: 1864 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: function.hpp Type: text/x-c++hdr Size: 2347 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: function.cpp Type: text/x-c++src Size: 24160 bytes Desc: not available URL: From roman.yakovenko at gmail.com Wed Jul 5 09:03:32 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 5 Jul 2006 10:03:32 +0300 Subject: [C++-sig] class registration - bug or feature? Message-ID: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> Hi. Please take a look on next code struct X{ void do_smth(); }; class_("X"); class_("X") .def( "do_smth", &X::do_smth ); Boost.Python reports a warning while registering class X second time: "to-Python converter for struct X already registered; second conversion method ignored." But, indeed Boost.Python continues to register the class - I mean, that Boost.Python adds functions to the already registered class. My question: is this a bug or it is a desired behaviour? Thanks. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From gleizesd at gmail.com Wed Jul 5 19:26:10 2006 From: gleizesd at gmail.com (Damien Gleizes) Date: Wed, 5 Jul 2006 17:26:10 +0000 (UTC) Subject: [C++-sig] class registration - bug or feature? References: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> Message-ID: I'm not a specialist but I would say that it is the desired behaviour: class_("X"); //register the class X class_("X") //register the class X again .def( "do_smth", &X::do_smth );//register the func do_smth in the class X You might probably want to do something like that: class_ MyClass("X"); MyClass.def( "do_smth", &X::do_smth ); I am not sure it is correct as I did'nt try... From gleizesd at gmail.com Wed Jul 5 19:32:08 2006 From: gleizesd at gmail.com (Damien Gleizes) Date: Wed, 5 Jul 2006 17:32:08 +0000 (UTC) Subject: [C++-sig] class registration - bug or feature? References: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> Message-ID: ooops, sorry I think I missunderstood the question... From kleistereimer at gmx.de Thu Jul 6 15:06:17 2006 From: kleistereimer at gmx.de (Kleistereimer) Date: Thu, 06 Jul 2006 13:06:17 +0000 Subject: [C++-sig] how to correctly delete stuff 'extract<>'ed from python? Message-ID: <44AD0AC9.3070209@gmx.de> hi! how to correctly delete stuff 'extract<>'ed from python? i have: python::object somepyobj = ... Tobj *obj = python::extract(somepyobj); obj->DoStuff(..); but the following line fails in debugmode: delete obj; because of it was allocated from another heap. errormsg is: _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)); in dbgdel.cpp(52) in releasemode everything is fine. (i think this problem is silently ignored then) i guess i have to replace delete obj; by something like: python::delete_(obj); ??? i use msvc 7.1 and boost 1.33.1 regards kl From achim-bpl at mol-net.com Thu Jul 6 15:44:31 2006 From: achim-bpl at mol-net.com (Achim H.) Date: Thu, 6 Jul 2006 15:44:31 +0200 Subject: [C++-sig] how to correctly delete stuff 'extract<>'ed from python? In-Reply-To: <44AD0AC9.3070209@gmx.de> References: <44AD0AC9.3070209@gmx.de> Message-ID: <200607061544.32057.achim-bpl@mol-net.com> The sad truth is: you have no direct control over the lifetime of *obj ! As long as somepyobj lives, *obj lives as well. One possibility is to set up a vector and put a copy of somepyobj (and probably more of the same) in there to keep up the reference count. Then, you only have to make sure that the vector is not (auto-)deleted before *obj is used for the last time. Or you do it the dirty way: Py_INCREF(somepyobj.ptr()); But a deliberate kill of *obj is impossible. Achim. Am Donnerstag, 6. Juli 2006 15:06 schrieb Kleistereimer: > hi! > > how to correctly delete stuff 'extract<>'ed from python? > i have: > > python::object somepyobj = ... > Tobj *obj = python::extract(somepyobj); > > obj->DoStuff(..); > > > but the following line fails in debugmode: > > delete obj; > > > because of it was allocated from another heap. errormsg is: > _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)); > in dbgdel.cpp(52) > > > in releasemode everything is fine. (i think this problem is silently > ignored then) > > > i guess i have to replace > > > delete obj; > by something like: > python::delete_(obj); From kleistereimer at gmx.de Thu Jul 6 17:54:10 2006 From: kleistereimer at gmx.de (Kleistereimer) Date: Thu, 06 Jul 2006 15:54:10 +0000 Subject: [C++-sig] extending a c++ object by overriding it's virtual functions.. In-Reply-To: <44A0955A.8060008@gmx.de> References: <44A0955A.8060008@gmx.de> Message-ID: <44AD3222.2050705@gmx.de> hi achim! doing it the dirty way works fine. i just hope that obj will be properly deleted once i do the corresponding DECREF... :-) doing it the clean way does not works. buffvector.erase(elem_to_be_deleted) has the same problem. (but i did not properly tested this one. maybe i did something wrong) thankyou kl From sbalasub at qualcomm.com Thu Jul 6 23:35:15 2006 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Thu, 6 Jul 2006 14:35:15 -0700 Subject: [C++-sig] [ vector | list ] indexing suite Message-ID: Roman, How do I get the pyplusplus support for this new indexing_v2 support? I can volunteer to test the code. Is this available in CVS ? Thanks, Shiva -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave at boost-consulting.com Fri Jul 7 07:22:27 2006 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 07 Jul 2006 01:22:27 -0400 Subject: [C++-sig] class registration - bug or feature? References: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> Message-ID: "Roman Yakovenko" writes: > Hi. Please take a look on next code > > struct X{ > void do_smth(); > }; > > class_("X"); > > class_("X") > .def( "do_smth", &X::do_smth ); > > Boost.Python reports a warning while registering class X second time: > "to-Python converter for struct X already registered; second > conversion method ignored." > But, indeed Boost.Python continues to register the class - I mean, > that Boost.Python adds functions to the already registered class. That's not the same as registering it again. > My question: is this a bug or it is a desired behaviour? Desired. Or at least, expected. There's been nothing better proposed. -- Dave Abrahams Boost Consulting www.boost-consulting.com From roman.yakovenko at gmail.com Fri Jul 7 08:04:16 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Fri, 7 Jul 2006 09:04:16 +0300 Subject: [C++-sig] class registration - bug or feature? In-Reply-To: References: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> Message-ID: <7465b6170607062304w2d3737cawe0df964987026d09@mail.gmail.com> On 7/7/06, David Abrahams wrote: > "Roman Yakovenko" writes: > > > Hi. Please take a look on next code > > > > struct X{ > > void do_smth(); > > }; > > > > class_("X"); > > > > class_("X") > > .def( "do_smth", &X::do_smth ); > > > > Boost.Python reports a warning while registering class X second time: > > "to-Python converter for struct X already registered; second > > conversion method ignored." > > But, indeed Boost.Python continues to register the class - I mean, > > that Boost.Python adds functions to the already registered class. > > That's not the same as registering it again. > > > My question: is this a bug or it is a desired behaviour? > > Desired. Or at least, expected. There's been nothing better > proposed. I just wanted to know whether I can write program that uses this feature or not. Thank you! -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From roman.yakovenko at gmail.com Fri Jul 7 08:11:19 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Fri, 7 Jul 2006 09:11:19 +0300 Subject: [C++-sig] [ vector | list ] indexing suite In-Reply-To: References: Message-ID: <7465b6170607062311v6c1311c1o48e9bba15be35bd3@mail.gmail.com> On 7/7/06, Balasubramanyam, Shivakumar wrote: > Roman, > > How do I get the pyplusplus support for this new indexing_v2 support? I can > volunteer to test the code. All you need is to enable it: mb = module_builder_t( ..., indexing_suite_version=2 ) More over, py++ allows you to mix indexing suites: you can use at the same time indexing suite 1 and 2 for different containers. > Is this available in CVS ? Yes, in subversion. There is only 1 detail I should add, but it works and works well. In most cases, you will not have to touch the code at all! I am working now on correcting /adding documentation. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From dave at boost-consulting.com Fri Jul 7 18:04:45 2006 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 07 Jul 2006 12:04:45 -0400 Subject: [C++-sig] class registration - bug or feature? References: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> <7465b6170607062304w2d3737cawe0df964987026d09@mail.gmail.com> Message-ID: "Roman Yakovenko" writes: > On 7/7/06, David Abrahams wrote: >> "Roman Yakovenko" writes: >> >> > Hi. Please take a look on next code >> > >> > struct X{ >> > void do_smth(); >> > }; >> > >> > class_("X"); >> > >> > class_("X") >> > .def( "do_smth", &X::do_smth ); >> > >> > Boost.Python reports a warning while registering class X second time: >> > "to-Python converter for struct X already registered; second >> > conversion method ignored." >> > But, indeed Boost.Python continues to register the class - I mean, >> > that Boost.Python adds functions to the already registered class. >> >> That's not the same as registering it again. >> >> > My question: is this a bug or it is a desired behaviour? >> >> Desired. Or at least, expected. There's been nothing better >> proposed. > > I just wanted to know whether I can write program that uses this feature or not. Oh, I suppose that you can, but I don't know why you'd want to. Why not just apply ".def" to the same object? -- Dave Abrahams Boost Consulting www.boost-consulting.com From roman.yakovenko at gmail.com Fri Jul 7 19:31:01 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Fri, 7 Jul 2006 20:31:01 +0300 Subject: [C++-sig] class registration - bug or feature? In-Reply-To: References: <7465b6170607050003u4486cc6ane7892369755cfc1a@mail.gmail.com> <7465b6170607062304w2d3737cawe0df964987026d09@mail.gmail.com> Message-ID: <7465b6170607071031w3992c345gc30a1e87c7a88e77@mail.gmail.com> On 7/7/06, David Abrahams wrote: > Oh, I suppose that you can, but I don't know why you'd want to. Why > not just apply ".def" to the same object? It is very simple. There are few really big projects ( TnFOX, Python-OGRE, PyOpenSG ) that uses pyplusplus. Almost all of them have small problem: dependency order and boost::python::arg default value. I failed to create a patch for Boost.Python that fixes the situation ( http://mail.python.org/pipermail/c++-sig/2006-July/010904.html ), also I was pretty close to provide solution. Boost.Python already provides the mechanism, that resolves the problem - def_visitor, but the changes I have to make to code generator are too big. I can not commit my self to this task :-(. So, I just searched for work around. This one seems to be the perfect one, and I need only few hours to implement it. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From rwgk at yahoo.com Fri Jul 7 20:26:04 2006 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 7 Jul 2006 11:26:04 -0700 (PDT) Subject: [C++-sig] class registration - bug or feature? In-Reply-To: <7465b6170607071031w3992c345gc30a1e87c7a88e77@mail.gmail.com> Message-ID: <20060707182604.71938.qmail@web31515.mail.mud.yahoo.com> --- Roman Yakovenko wrote: > Boost.Python already provides the mechanism, that resolves the problem > - def_visitor, but the changes I have to make to code generator are > too big. > I can not commit my self to this task :-(. So, I just searched for work > around. > This one seems to be the perfect one, and I need only few hours to implement > it. David, would it be feasible to formalize this approach? I had situations, too, in which it was quite inconvenient to drag around the class_ object. It would be nice to be able to do something like this: file1.cpp class_, shared_ptr, noncopyable>("X"); file2.cpp registered_class() .def("foo", &X::foo) ; I.e. the new thing here would be registered_class<>, where I don't have to repeat bases, holder, etc. It would be my responsibility to make sure the primary class_<> is processed (at runtime) before registered_class<>. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From dave at boost-consulting.com Fri Jul 7 21:06:11 2006 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 07 Jul 2006 15:06:11 -0400 Subject: [C++-sig] class registration - bug or feature? References: <7465b6170607071031w3992c345gc30a1e87c7a88e77@mail.gmail.com> <20060707182604.71938.qmail@web31515.mail.mud.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > --- Roman Yakovenko wrote: > >> Boost.Python already provides the mechanism, that resolves the problem >> - def_visitor, but the changes I have to make to code generator are >> too big. >> I can not commit my self to this task :-(. So, I just searched for work >> around. >> This one seems to be the perfect one, and I need only few hours to implement >> it. > > David, would it be feasible to formalize this approach? I had situations, too, > in which it was quite inconvenient to drag around the class_ object. It > would be nice to be able to do something like this: > > file1.cpp > > class_, shared_ptr, noncopyable>("X"); > > file2.cpp > > registered_class() > .def("foo", &X::foo) > ; > > I.e. the new thing here would be registered_class<>, where I don't have to > repeat bases, holder, etc. It would be my responsibility to make sure the > primary class_<> is processed (at runtime) before registered_class<>. Yes, I think that's feasible. -- Dave Abrahams Boost Consulting www.boost-consulting.com From roman.yakovenko at gmail.com Sun Jul 9 09:36:19 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Sun, 9 Jul 2006 10:36:19 +0300 Subject: [C++-sig] [ vector | list ] indexing suite In-Reply-To: References: Message-ID: <7465b6170607090036h65bab922v3da10778f6ef4ede@mail.gmail.com> On 7/7/06, Balasubramanyam, Shivakumar wrote: > How do I get the pyplusplus support for this new indexing_v2 support? I can > volunteer to test the code. > > Is this available in CVS ? > Good morning, I just commited few changes for code generation of indexing suite v2. Now, it almost hands-freee solution. I also tested( code generation only ) it on big and complex project. It could be nice if you can test it. Thanks. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From blairs at free.fr Mon Jul 10 10:44:49 2006 From: blairs at free.fr (blairs at free.fr) Date: Mon, 10 Jul 2006 10:44:49 +0200 Subject: [C++-sig] back-embedding... is this possible? Message-ID: <1152521089.44b213811f421@imp4-g19.free.fr> ok my project looks like this : // my boost-python module struct A { A(){} void toto(){...} }; BOOST_PYTHON_MODULE(my_module) { class_("A", init<>()) .def("toto", &A::toto); } /// my final C++ program int main() { A a; //do sum c++ stuff //start the python interpreter... PyRun_String("import my_module"); reverse_extract>(a, __mainmodule__,"a"); //this is, symbolically, what I want to do PyRun_String("a.toto()"); ... } is this behaviour possible to create? From roman.yakovenko at gmail.com Mon Jul 10 10:54:37 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Mon, 10 Jul 2006 11:54:37 +0300 Subject: [C++-sig] back-embedding... is this possible? In-Reply-To: <1152521089.44b213811f421@imp4-g19.free.fr> References: <1152521089.44b213811f421@imp4-g19.free.fr> Message-ID: <7465b6170607100154v1d0f6eaan5cdc2e989cd2db55@mail.gmail.com> On 7/10/06, blairs at free.fr wrote: > ok my project looks like this : > > // my boost-python module > > struct A > { > A(){} > void toto(){...} > }; > > BOOST_PYTHON_MODULE(my_module) > { > class_("A", init<>()) > .def("toto", &A::toto); > } > > > > /// my final C++ program > > int main() > { > A a; > //do sum c++ stuff > > //start the python interpreter... > > PyRun_String("import my_module"); > reverse_extract>(a, __mainmodule__,"a"); //this is, symbolically, what > I want to do > PyRun_String("a.toto()"); > > ... > } > > is this behaviour possible to create? This does almost exactly what you want: http://boost.org/libs/python/doc/tutorial/doc/html/python/embedding.html#python.using_the_interpreter -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From blairs at free.fr Mon Jul 10 12:34:47 2006 From: blairs at free.fr (blairs at free.fr) Date: Mon, 10 Jul 2006 12:34:47 +0200 Subject: [C++-sig] Re :Re: back-embedding... is this possible? In-Reply-To: References: Message-ID: <1152527687.44b22d473317f@imp5-g19.free.fr> > > ok my project looks like this : > > > > // my boost-python module > > > > struct A > > { > > A(){} > > void toto(){...} > > }; > > > > BOOST_PYTHON_MODULE(my_module) > > { > > class_("A", init<>()) > > .def("toto", &A::toto); > > } > > > > > > > > /// my final C++ program > > > > int main() > > { > > A a; > > //do sum c++ stuff > > > > //start the python interpreter... > > > > PyRun_String("import my_module"); > > reverse_extract>(a, __mainmodule__,"a"); //this is, symbolically, > what > > I want to do > > PyRun_String("a.toto()"); > > > > ... > > } > > > > is this behaviour possible to create? > > This does almost exactly what you want: > http://boost.org/libs/python/doc/tutorial/doc/html/python/embedding.html#python.using_the_interpreter > I can create the instance in python with PyRun_String("a =A()"); then handle a in C++ with A& a = extract(main_namespace["a"]); but I don't get it from this tutorial how to create the instance in c++ then handle it in python From roman.yakovenko at gmail.com Mon Jul 10 14:11:06 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Mon, 10 Jul 2006 15:11:06 +0300 Subject: [C++-sig] Re :Re: back-embedding... is this possible? In-Reply-To: <1152527687.44b22d473317f@imp5-g19.free.fr> References: <1152527687.44b22d473317f@imp5-g19.free.fr> Message-ID: <7465b6170607100511s6d30cf49y55bed449d71a773d@mail.gmail.com> On 7/10/06, blairs at free.fr wrote: > > I can create the instance in python with > PyRun_String("a =A()"); > then handle a in C++ with > A& a = extract(main_namespace["a"]); > > but I don't get it from this tutorial how to create the instance in c++ then > handle it in python boost::shared_ptr a( new A() ); boost::python::object py_a( a ); Now, I think, you have to inject py_a to appropriate scope. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From sbalasub at qualcomm.com Wed Jul 12 23:48:19 2006 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Wed, 12 Jul 2006 14:48:19 -0700 Subject: [C++-sig] [ vector | list ] indexing suite Message-ID: I am curious about one thing. Before updating the code to use this new indexing_suite_v2, was there any handwritten code added to the generated boost.python code. If yes, how was the upgrade done? py++ would overwrite the files right? Thanks, Shiva -------------- next part -------------- An HTML attachment was scrubbed... URL: From mharidev at qualcomm.com Thu Jul 13 01:18:50 2006 From: mharidev at qualcomm.com (Haridev, Meghana) Date: Wed, 12 Jul 2006 16:18:50 -0700 Subject: [C++-sig] Base class defined in other header file not included in bp::bases<> Message-ID: <5383A81D5EB8F14FBDB487D9B5FBEA880152C02F@NAEX11.na.qualcomm.com> Hi Folks, I'm having some trouble generating boost-python wrapper code using pyplusplus for a derived class which has one of its base classes defined in another file. Simple scenario: mydir/ other.hpp: class baseB{ }; hierarchy.hpp: #include "other.hpp" class baseA{ }; class derivedC: public baseA, public baseB{ }; generate_code.py: import os from pyplusplus import module_builder mb = module_builder.module_builder_t( files=['hierarchy.hpp'] ) mb.build_code_creator( module_name='inherit' ) mb.code_creator.user_defined_directories.append( os.path.abspath('.') ) mb.write_module('boost_hierarchy.cpp') ------------------------------------------------------------------------ ------------------------------------------------- Generated code (boost_hierarchy.cpp) looks like this: // This file has been generated by pyplusplus. #include "boost/python.hpp" #include "hierarchy.hpp" namespace bp = boost::python; BOOST_PYTHON_MODULE(inherit){ bp::class_< baseA >( "baseA" ); bp::class_< derivedC, bp::bases< baseA > >( "derivedC" ); } How can I get pyplusplus to add 'baseB' to bp::bases<> for 'derivedC' class when 'baseB' class is defined in another file (present in the same directory or different directory)? When I move the definition of 'baseB' class to hierarchy.hpp, boost wrapper for 'derivedC' is correctly generated as: bp::class_< derivedC, bp::bases< baseA, baseB > >( "derivedC" ); Thanks, -Meghana. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Thu Jul 13 07:00:35 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Thu, 13 Jul 2006 08:00:35 +0300 Subject: [C++-sig] [ vector | list ] indexing suite In-Reply-To: References: Message-ID: <7465b6170607122200o46cce5b9q177f7b00f7651957@mail.gmail.com> On 7/13/06, Balasubramanyam, Shivakumar wrote: > > > > I am curious about one thing. Before updating the code to use this new > indexing_suite_v2, was there any handwritten code added to the generated > boost.python code. Sorry, I don't understand the question :-( > If yes, how was the upgrade done? py++ would overwrite the files right? > -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From roman.yakovenko at gmail.com Thu Jul 13 07:18:36 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Thu, 13 Jul 2006 08:18:36 +0300 Subject: [C++-sig] Base class defined in other header file not included in bp::bases<> In-Reply-To: <5383A81D5EB8F14FBDB487D9B5FBEA880152C02F@NAEX11.na.qualcomm.com> References: <5383A81D5EB8F14FBDB487D9B5FBEA880152C02F@NAEX11.na.qualcomm.com> Message-ID: <7465b6170607122218j6aeb97c4y2d1c60cff878037f@mail.gmail.com> On 7/13/06, Haridev, Meghana wrote: > Hi Folks, > I'm having some trouble generating boost-python wrapper code using > pyplusplus for a derived class which has one of its base classes defined in > another file. > How can I get pyplusplus to add 'baseB' to bp::bases<> for 'derivedC' class > when 'baseB' class is defined in another file (present in the same directory If "other.hpp" presents in the same directory it will just work. > or different directory)? In this case baseB class will be excluded. The idea behind such behaviour is next: there is one directory that contains library interface and many directories that contain implementation details. So, by default pyplusplus excludes from generation all declarations defined in other directories. You can find more information here: http://language-binding.net/pyplusplus/tutorials/module_builder/module_builder.html Next few lines of code will include baseB: mb = module_builder_t( ... ) mb.class_( 'baseB' ).include() #or if you want to include all declarations from directory Y: mb.decls( header_dir=Y ).include() I hope, this will help you. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From mharidev at qualcomm.com Thu Jul 13 20:20:09 2006 From: mharidev at qualcomm.com (Haridev, Meghana) Date: Thu, 13 Jul 2006 11:20:09 -0700 Subject: [C++-sig] Base class defined in other header file not includedin bp::bases<> In-Reply-To: <7465b6170607122218j6aeb97c4y2d1c60cff878037f@mail.gmail.com> Message-ID: <5383A81D5EB8F14FBDB487D9B5FBEA880152C24D@NAEX11.na.qualcomm.com> Hi Roman, Thanks for your help! Another question: Say that I have already written manually boost-python wrappers for baseB class (present in different directory) and have a shared library for it. Now I want to use pyplusplus to generate the boost-python wrappers for derivedC class. Like you suggested, if I add: mb.class_( 'baseB' ).include() It will give me the following generated code: bp::class_< baseB >( "baseB" ); bp::class_< baseA >( "baseA" ); bp::class_< derivedC, bp::bases< baseA, baseB > >( "derivedC" ); But what if I don't want pyplusplus to expose baseB again (I am going to link baseB's shared library with derivedC's boost wrapper) but I still want it to appear in bp::bases - is it possible to do that using pyplusplus? In other words, I want the generated code to look like this: /* bp::class_< baseB >( "baseB" ); - Do not want to generate */ bp::class_< baseA >( "baseA" ); bp::class_< derivedC, bp::bases< baseA, baseB > >( "derivedC" ); Thanks, -Meghana. -----Original Message----- From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Roman Yakovenko Sent: Wednesday, July 12, 2006 10:19 PM To: Development of Python/C++ integration Subject: Re: [C++-sig] Base class defined in other header file not includedin bp::bases<> On 7/13/06, Haridev, Meghana wrote: > Hi Folks, > I'm having some trouble generating boost-python wrapper code using > pyplusplus for a derived class which has one of its base classes defined in > another file. > How can I get pyplusplus to add 'baseB' to bp::bases<> for 'derivedC' class > when 'baseB' class is defined in another file (present in the same directory If "other.hpp" presents in the same directory it will just work. > or different directory)? In this case baseB class will be excluded. The idea behind such behaviour is next: there is one directory that contains library interface and many directories that contain implementation details. So, by default pyplusplus excludes from generation all declarations defined in other directories. You can find more information here: http://language-binding.net/pyplusplus/tutorials/module_builder/module_b uilder.html Next few lines of code will include baseB: mb = module_builder_t( ... ) mb.class_( 'baseB' ).include() #or if you want to include all declarations from directory Y: mb.decls( header_dir=Y ).include() I hope, this will help you. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Fri Jul 14 10:34:43 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Fri, 14 Jul 2006 11:34:43 +0300 Subject: [C++-sig] Base class defined in other header file not includedin bp::bases<> In-Reply-To: <5383A81D5EB8F14FBDB487D9B5FBEA880152C24D@NAEX11.na.qualcomm.com> References: <7465b6170607122218j6aeb97c4y2d1c60cff878037f@mail.gmail.com> <5383A81D5EB8F14FBDB487D9B5FBEA880152C24D@NAEX11.na.qualcomm.com> Message-ID: <7465b6170607140134r5534654dtb54cec53cd930fa7@mail.gmail.com> On 7/13/06, Haridev, Meghana wrote: > In other words, I want the generated code to look like this: > /* bp::class_< baseB >( "baseB" ); - Do not want to generate */ > > bp::class_< baseA >( "baseA" ); > > bp::class_< derivedC, bp::bases< baseA, baseB > >( "derivedC" ); It is possible, but you will have to understand a little how code creators works. There are few ways to solve the problem. 1. Exclude baseB from being generated, and add it manually to derivedC. Take a look on pyplusplus/code_creators/class_declaration.py - class "class_t", method - _generate_bases. You will have to redefine this method, something like this: def my_generate_bases( self, base_creators ): if self.declaration.Name != 'derivedC': run current code else: your logic is going her pyplusplus.code_creators.class_t._generate_bases = my_generate_bases 2. You can include baseB to be generated, but instead of generating code it will generate empty string: mb = module_builder_t( ... ) mb.build_code_creators( ... ) from pyplusplus import code_creators baseB = mb.class_( 'baseB' ) baseB_creators \ = code_creators.creator_finder.find_by_declaration( lambda decl: decl is baseB #what to look , mb.code_creator ) #where #now, we have to leave only class_t and class_wrapper_t code creators relevant_clss = ( code_creators.class_t, code_creators.class_wrapper_t ) baseB_creators = filters( lambda c: isinstance( c, relevant_clss ) ) for c in baseB_creators: c.create = lambda self: '' Second approach is better, because in this case pyplusplus will take into account all data available from baseB, but will not generate code. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From samwzm at yahoo.com Mon Jul 17 23:41:05 2006 From: samwzm at yahoo.com (sam wang) Date: Mon, 17 Jul 2006 14:41:05 -0700 (PDT) Subject: [C++-sig] problem about conertting c++ method to python Message-ID: <20060717214105.90826.qmail@web51604.mail.yahoo.com> hi, there, I want to convert a little c++ method to python. it just retrieves the length of some unsigned values from a vector according to some rules. one of them seems work while another one didn't work, could you please let me know what's wrong and how I should correct it? any hint will great appreciate! Sammy the following is the source code of the method: *****************c++ function and converted python which seems work**************** c++: int getint(uchar *&p) { int c = *((char *)p); p++; if(c==-128) { int n = *p++; n |= *((char *)p)<<8; p++; return n;} else if(c==-127) { int n = *p++; n |= *p++<<8; n |= *p++<<16; return n|(*p++<<24); } else return c; }; python: def __getint(this): if this.p[0]==-128: return this.p[1] | (this.p[1]<<8), 3 elif this.p[0] == -127: return this.p[1] | (this.p[2] <<8) | (this.p[3] << 16) | (this.p[4]), 5 else: return this.p[0], 1 ************another c++ method and converted python which didn't work******************* c++: int getuint(uchar *&p) { int n = *p++; if(n & 0x80) { n += (*p++ << 7) - 0x80; if(n & (1<<14)) n += (*p++ << 14) - (1<<14); if(n & (1<<21)) n += (*p++ << 21) - (1<<21); if(n & (1<<28)) n |= 0xF0000000; }; return n; }; python: def __getuint(this): n = this.p[0] s = 1 if (n & 0x80): n += (this.p[0] << 7) - 0x80; s += 1 if (n & (1<<14)): n += (this.p[1] << 14) - (1<<14); s += 1 if (n & (1<<21)): n += (this.p[2] << 21) - (1<<21); s += 1 if (n & (1<<28)): n |= 0xF0000000; return n, s __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From dave at boost-consulting.com Tue Jul 18 16:46:52 2006 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 18 Jul 2006 10:46:52 -0400 Subject: [C++-sig] problem about conertting c++ method to python References: <20060717214105.90826.qmail@web51604.mail.yahoo.com> Message-ID: sam wang writes: > hi, there, > > I want to convert a little c++ method to python. it just retrieves the length of some unsigned > values from a vector according to some rules. > > one of them seems work while another one didn't work, could you please let me know what's wrong > and how I should correct it? > > any hint will great appreciate! > Sammy You seem to have an expectation that a Python int will exhibit modular arithmetic like a C++ unsigned int will (if unsigned int is 32 bits). Try python -c "print 1 << 157" and see what you get. :) -- Dave Abrahams Boost Consulting www.boost-consulting.com From tore.birkeland at gmail.com Wed Jul 19 15:11:54 2006 From: tore.birkeland at gmail.com (Tore Birkeland) Date: Wed, 19 Jul 2006 15:11:54 +0200 Subject: [C++-sig] Problem with custom lvalue converter Message-ID: Hi I'm using boost::python to create a wrapper for my quantum mechanics propagator, and I've run into the following problem: When i create a custom lvalue converter, and instance a new c++ class from within the construct() method (as described in the FAQ), the destructor for that object is called twice! Can someone tell me what I am doing wrong, and how to avoid it? I have attached c++ and .py files that reproduce the problem. When destructorproblem.py is run, i get the following output: > python destructorproblem.py Constructing A Got A Destructing A Destructing A best regards, Tore Birkeland -------------- next part -------------- A non-text attachment was scrubbed... Name: destructorproblem.cpp Type: text/x-c++src Size: 822 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: destructorproblem.py Type: application/octet-stream Size: 109 bytes Desc: not available URL: From Naceur.Meskini at sophia.inria.fr Wed Jul 19 18:30:15 2006 From: Naceur.Meskini at sophia.inria.fr (Naceur Meskini) Date: Wed, 19 Jul 2006 18:30:15 +0200 Subject: [C++-sig] The first beta release of CGAL-Python is available. Message-ID: <44BE5E17.3030107@sophia.inria.fr> Hi, We are pleased to announce the availability of the CGAL-Python first beta release 0.9, the Python bindings for CGAL. It allows to easily use the robust algorithms and data structures of CGAL under Python. This first beta release of CGAL-Python provides the following modules: * Triangulations_2: This module corresponds to the Triangulation_2 package of CGAL that allows to build and handle various triangulations for point sets in two dimensions. It contains the following classes: - Triangulation_2 - Delaunay_triangulation_2 - Delaunay_constrained_triangulation_2 - Constrained_triangulation_2 - Constrained_triangulation_plus_2 * Triangulations_3: This module allows to build and handle triangulations for point sets in three dimensions. Currently this module provides two classes: - Triangulation_3 - Delaunay_triangulation_3 * Alpha_shapes_2 * Alpha_shapes_3 * Polyhedron - Poyhedron_3 * Convex_hull_2 * Geometric_Optimisation - Min_ellipse_2 - Min_circle_2 - Min_sphere_3 - Min_annulus_2 - Min_annulus_3 * Mesh_2 * Kernel - Point_2(3) - Ray_2(3) - And many other basic geometric objects. More information about CGAL-Python such as an online manual, a mailing-list and downloading instructions can be found on the web site http://cgal-python.gforge.inria.fr/. We welcome any feedback on this early release. We also would like to take the opportunity of this mail to recall that another interpreted language provides bindings to CGAL: the SCILAB platform (a Matlab-like environment), using the CGLAB toolbox (http://cglab.gforge.inria.fr/). ------------- Naceur MESKINI. INRIA Sophia-Antipolis. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sbalasub at qualcomm.com Wed Jul 19 20:41:37 2006 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Wed, 19 Jul 2006 11:41:37 -0700 Subject: [C++-sig] code generation of two scenarios Message-ID: Hi, I have the code generated for two scenarios below and I do not understand the difference in behavior for *test* function, In this first case, I would need to write the hand-wrapper code for test(immutable &int) function. The differences in code are that, the sample 2 code has an array instantiation, which would generate the py++ array wrapper. Where as the second sample has this built-in, which would return me a tuple of (int,int) Any reasons why? ************************************************************************ ********************************************* #include class A { public: static int test(unsigned int & num) ; }; // This file has been generated by pyplusplus. #include "boost/python.hpp" #include "/local/mnt/workspace/software/pyplusplus-0.8.0/tests/csw/test2/A.h" namespace bp = boost::python; BOOST_PYTHON_MODULE(test2){ bp::class_< A >( "A" ) .def( "test" , &::A::test , ( bp::arg("num") ) , bp::default_call_policies() ) .staticmethod( "test" ); } ************************************************************************ ********************************************* ************************************************************************ ********************************************* #include const unsigned int COUNT = 100; class A { public: static int test(unsigned int & num) ; static unsigned int _indexArray[COUNT]; }; // This file has been generated by pyplusplus. #include "boost/python.hpp" #include "__array_1.pypp.hpp" #include "/local/mnt/workspace/software/pyplusplus-0.8.0/tests/csw/test2/A.h" namespace bp = boost::python; struct A_wrapper : A, bp::wrapper< A > { A_wrapper(A const & arg ) : A( arg ) , bp::wrapper< A >(){ // copy constructor } A_wrapper() : A() , bp::wrapper< A >(){ // null constructor } pyplusplus::containers::static_sized::array_1_t< unsigned int, 100 > pyplusplus__indexArray_wrapper(){ return pyplusplus::containers::static_sized::array_1_t< unsigned int, 100 >( _indexArray ); } }; BOOST_PYTHON_MODULE(test2){ { //::A typedef bp::class_< A_wrapper > A_exposer_t; A_exposer_t A_exposer = A_exposer_t( "A" ); bp::scope A_scope( A_exposer ); { //::A::test typedef int ( *function_ptr_t )( unsigned int & ); A_exposer.def( "test" , function_ptr_t( &::A::test ) , ( bp::arg("num") ) , bp::default_call_policies() ); } pyplusplus::containers::static_sized::register_array_1< unsigned int, 100, bp::default_call_policies >( "__array_1_unsigned_int_100" ); A_exposer.add_static_property( "_indexArray" , bp::make_function( (pyplusplus::containers::static_sized::array_1_t< unsigned int, 100 > ( A_wrapper::* )( ) )(&A_wrapper::pyplusplus__indexArray_wrapper) ) );; A_exposer.staticmethod( "test" ); } bp::scope().attr("COUNT") = COUNT; } ************************************************************************ ********************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Wed Jul 19 21:03:48 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 19 Jul 2006 22:03:48 +0300 Subject: [C++-sig] code generation of two scenarios In-Reply-To: References: Message-ID: <7465b6170607191203l7af3af58v22326262400e354@mail.gmail.com> On 7/19/06, Balasubramanyam, Shivakumar wrote: > Hi, > > I have the code generated for two scenarios below and I do not understand > the difference in behavior for *test* function, > > In this first case, I would need to write the hand-wrapper code for > test(immutable &int) function. > > The differences in code are that, the sample 2 code has an array > instantiation, which would generate the py++ array wrapper. > > Where as the second sample has this built-in, which would return me a tuple > of (int,int) > > Any reasons why? Sorry, but I don't understand your question. What tuple you are talking about? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From sbalasub at qualcomm.com Wed Jul 19 21:13:39 2006 From: sbalasub at qualcomm.com (Balasubramanyam, Shivakumar) Date: Wed, 19 Jul 2006 12:13:39 -0700 Subject: [C++-sig] code generation of two scenarios Message-ID: Ooops, The part where I said I get the return of tuple for test function in my second implementation is wrong. I was using the shared objects of earlier implementation which had the py++ generating the hand-wrapped code for in-out parameters. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Wed Jul 19 21:23:27 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 19 Jul 2006 22:23:27 +0300 Subject: [C++-sig] code generation of two scenarios In-Reply-To: References: Message-ID: <7465b6170607191223x6eba0a32n2bf12b66e73c3e76@mail.gmail.com> On 7/19/06, Balasubramanyam, Shivakumar wrote: > Ooops, The part where I said I get the return of tuple for test function in > my second implementation is wrong. > > I was using the shared objects of earlier implementation which had the py++ > generating the hand-wrapped code for in-out parameters. Does it mean, that you don't have problem any more? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From rwgk at yahoo.com Thu Jul 20 12:53:14 2006 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 20 Jul 2006 03:53:14 -0700 (PDT) Subject: [C++-sig] Problem with custom lvalue converter In-Reply-To: Message-ID: <20060720105314.83571.qmail@web31512.mail.mud.yahoo.com> --- Tore Birkeland wrote: > void TestA(A in) > { > cout << "Got A" << endl; > } You are passing A by value, which means you are invoking the copy constructor. Try void TestA(A const& in) __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From tore.birkeland at gmail.com Thu Jul 20 13:25:28 2006 From: tore.birkeland at gmail.com (Tore Birkeland) Date: Thu, 20 Jul 2006 13:25:28 +0200 Subject: [C++-sig] Problem with custom lvalue converter In-Reply-To: <20060720105314.83571.qmail@web31512.mail.mud.yahoo.com> References: <20060720105314.83571.qmail@web31512.mail.mud.yahoo.com> Message-ID: Ah, thanks! Suddenly it all makes a hole lot more sense :) On 7/20/06, Ralf W. Grosse-Kunstleve wrote: > --- Tore Birkeland wrote: > > void TestA(A in) > > { > > cout << "Got A" << endl; > > } > > You are passing A by value, which means you are invoking the copy constructor. > Try > > void TestA(A const& in) > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From jan at langernetz.de Thu Jul 20 13:39:16 2006 From: jan at langernetz.de (Jan Langer) Date: Thu, 20 Jul 2006 13:39:16 +0200 Subject: [C++-sig] Pyplusplus - anonymous union Message-ID: Hello, I'm using pyplusplus to generate python-bindings for a C API. However, there are several unions, and I just don't know how to handle them. The following example code from the API: typedef struct { int offset; int dataType; union { char *sdata; int idata; } u; } A; generates this Boost.Python code: bp::class_< A >( "A" ) .def_readwrite( "offset", &A::offset ) .def_readwrite( "dataType", &A::dataType ) .def_readonly( "u", &A::u ); and it does not compile on gcc 3.3.2 with this error: error: template-argument `A:: A::*' uses anonymous type Is there a solution? I have already searched the news archives, but haven't found useful hints. Thanks, Jan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature URL: From roman.yakovenko at gmail.com Thu Jul 20 19:21:14 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Thu, 20 Jul 2006 20:21:14 +0300 Subject: [C++-sig] Pyplusplus - anonymous union In-Reply-To: References: Message-ID: <7465b6170607201021j2ff8e92cy154d70e95c565455@mail.gmail.com> On 7/20/06, Jan Langer wrote: > Hello, > I'm using pyplusplus to generate python-bindings for a C API. mb = module_builder_t( ... ) #The code in subversion does it for you mb.classes( name='' ).exclude() Next code is copied from Python-OGRE bindings: def fix_unnamed_classes (mb): ogre_ns = mb.namespace ('Ogre') print len (ogre_ns.classes ('')) / 2 for unnamed_cls in ogre_ns.classes( '' ): named_parent = unnamed_cls.parent if not named_parent.name: named_parent = named_parent.parent for mvar in unnamed_cls.public_members: if not mvar.name: continue if declarations.is_array (mvar.type): template = '''def_readonly("%(mvar)s", &Ogre::%(parent)s::%(mvar)s)''' else: template = '''def_readwrite("%(mvar)s", &Ogre::%(parent)s::%(mvar)s)''' named_parent.add_code( template % dict( mvar=mvar.name, parent=named_parent.name ) ) This should work. P.S. You project is 3rd project that need this feature, may be this is a time to implement it :-) -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From daniel at boost-consulting.com Sun Jul 23 13:06:32 2006 From: daniel at boost-consulting.com (Daniel Wallin) Date: Sun, 23 Jul 2006 13:06:32 +0200 Subject: [C++-sig] Protected destructor compile error In-Reply-To: References: Message-ID: David Abrahams wrote: > Did I mention I'm not making any heavy decisions while I'm on > vacation? Why don't y'all discuss the tradeoffs here and decide > whether it's worth it. I think the incompatibility problem makes the change not worth the trouble. This issue isn't common enough. Introducing a metafunction that can be specialized by the user OTOH is a really trivial change. I have code ready with a "is_destructible" metafunction, shall I add tests and check in? -- Daniel Wallin Boost Consulting www.boost-consulting.com From kanand at qualcomm.com Wed Jul 26 03:08:22 2006 From: kanand at qualcomm.com (Anand, Kumar) Date: Tue, 25 Jul 2006 18:08:22 -0700 Subject: [C++-sig] Exposing Enums with same values Message-ID: Hi, I am trying to expose an Enum (defined in C++) to Python using Boost Python. //type.cpp file // Please note that the 2 of the enums have the same value. typedef enum { HOST_TYPE_AT = 1, HOST_TYPE_AP = 0, HOST_TYPE_COMMON = 0 HOST_TYPE_INVALID = 2 } HWM_HostType; //boost_type.cpp #include #include #include #include "type.cpp" namespace bp = boost::python; BOOST_PYTHON_MODULE (Boost_Test) { bp::enum_< HWM_HostType >(" HWM_HostType ") .value("HOST_TYPE_AT ", HOST_TYPE_AT) .value("HOST_TYPE_AP ", HOST_TYPE_AP) .value("HOST_TYPE_COMMON ", HOST_TYPE_COMMON) .value("HOST_TYPE_INVALID ", HOST_TYPE_INVALID) .export_values() ; } //Build goes fine. SO FAR SO GOOD!! But when I use it in Python I get an error. //my python script import Boost_Test print Boost_Test.HOST_TYPE_AT print Boost_Test.HOST_TYPE_AP print Boost_Test.HOST_TYPE_COMMON AttributeError: 'module' object has no attribute HOST_TYPE_COMMON' Any suggestions? When I try to assign different values to the enums, everything works fine. Thanks Kumar -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Wed Jul 26 06:45:30 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 26 Jul 2006 07:45:30 +0300 Subject: [C++-sig] Exposing Enums with same values In-Reply-To: References: Message-ID: <7465b6170607252145pc80d0d3k8bd96cbf146ca35f@mail.gmail.com> On 7/26/06, Anand, Kumar wrote: > Hi, > I am trying to expose an Enum (defined in C++) to Python using Boost Python. > // Please note that the 2 of the enums have the same value. Somewhere there is a patch that fixes this situation. You can also fix it manually from Python: import Boost_Test Boost_Test.HOST_TYPE_COMMON = Boost_Test.HOST_TYPE_AT -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From mharidev at qualcomm.com Wed Jul 26 21:01:26 2006 From: mharidev at qualcomm.com (Haridev, Meghana) Date: Wed, 26 Jul 2006 12:01:26 -0700 Subject: [C++-sig] Base class defined in other header file notincludedin bp::bases<> In-Reply-To: <7465b6170607140134r5534654dtb54cec53cd930fa7@mail.gmail.com> Message-ID: <5383A81D5EB8F14FBDB487D9B5FBEA88015C229E@NAEX11.na.qualcomm.com> Hi Roman, I tried your second approach since it goes better with our environment. I made some changes (highlighted in bold below) to get it to run. It works fine till I come to the point where I need to write the module to multiple files (or even just a single file). mb = module_builder_t( ... ) mb.class_('baseB').include() #because baseB defined in header file in diff directory mb.build_code_creators( ... ) from pyplusplus import code_creators baseB = mb.class_( 'baseB' ) baseB_creators \ = code_creators.creator_finder.find_by_declaration( lambda decl: decl is baseB #what to look , mb.code_creator ) #where #now, we have to leave only class_t and class_wrapper_t code creators relevant_clss = ( code_creators.class_t, code_creators.class_wrapper_t ) baseB_creators = filter( lambda c: isinstance( c, relevant_clss ), baseB_creators ) for c in baseB_creators: c.create = lambda self: '' mb.split_module( os.path.abspath('.') ) I get this error: File "generate_code.py", line 80, in export mb.split_module( os.path.abspath('.') ) File "...pyplusplus/module_builder/builder.py", line 224, in split_module file_writers.write_multiple_files( self.code_creator, dir_name ) File "...pyplusplus/file_writers/__init__.py", line 32, in write_multiple_files mfs.write() File "...pyplusplus/file_writers/multiple_files.py", line 253, in write map( self.split_class, class_creators ) File "...pyplusplus/file_writers/multiple_files.py", line 171, in split_class self.__split_class_impl( class_creator ) File "...pyplusplus/file_writers/multiple_files.py", line 148, in __split_class_impl , [class_creator] )) File "...pyplusplus/file_writers/multiple_files.py", line 126, in create_source answer.append( creator.wrapper.create() ) TypeError: () takes exactly 1 argument (0 given) Seems like it doesn't like the empty string we give to create... I also tried just writing the module to a single file: mb.write_module( os.path.join( os.path.abspath('.'), settings.module_name + '.cpp' ) ) File "...pyplusplus/module_builder/builder.py", line 215, in write_module file_writers.write_file( self.code_creator, file_name ) File "...pyplusplus/file_writers/__init__.py", line 28, in write_file sf.write() File "...pyplusplus/file_writers/single_file.py", line 24, in write self.write_file( self.file_name, self.extmodule.create() ) File "...pyplusplus/code_creators/code_creator.py", line 93, in create code = self._create_impl() File "...pyplusplus/code_creators/module.py", line 195, in _create_impl code = compound.compound_t.create_internal_code( self.creators[index:] ) File "...pyplusplus/code_creators/compound.py", line 56, in create_internal_code internals = map( lambda expr: expr.create(), creators ) File "...pyplusplus/code_creators/compound.py", line 56, in internals = map( lambda expr: expr.create(), creators ) TypeError: () takes exactly 1 argument (0 given) Any suggestions? Thanks, -Meghana. -----Original Message----- From: c++-sig-bounces+mharidev=qualcomm.com at python.org [mailto:c++-sig-bounces+mharidev=qualcomm.com at python.org] On Behalf Of Roman Yakovenko Sent: Friday, July 14, 2006 1:35 AM To: Development of Python/C++ integration Subject: Re: [C++-sig] Base class defined in other header file notincludedin bp::bases<> On 7/13/06, Haridev, Meghana wrote: > In other words, I want the generated code to look like this: > /* bp::class_< baseB >( "baseB" ); - Do not want to generate */ > > bp::class_< baseA >( "baseA" ); > > bp::class_< derivedC, bp::bases< baseA, baseB > >( "derivedC" ); It is possible, but you will have to understand a little how code creators works. There are few ways to solve the problem. 1. Exclude baseB from being generated, and add it manually to derivedC. Take a look on pyplusplus/code_creators/class_declaration.py - class "class_t", method - _generate_bases. You will have to redefine this method, something like this: def my_generate_bases( self, base_creators ): if self.declaration.Name != 'derivedC': run current code else: your logic is going her pyplusplus.code_creators.class_t._generate_bases = my_generate_bases 2. You can include baseB to be generated, but instead of generating code it will generate empty string: mb = module_builder_t( ... ) mb.build_code_creators( ... ) from pyplusplus import code_creators baseB = mb.class_( 'baseB' ) baseB_creators \ = code_creators.creator_finder.find_by_declaration( lambda decl: decl is baseB #what to look , mb.code_creator ) #where #now, we have to leave only class_t and class_wrapper_t code creators relevant_clss = ( code_creators.class_t, code_creators.class_wrapper_t ) baseB_creators = filters( lambda c: isinstance( c, relevant_clss ) ) for c in baseB_creators: c.create = lambda self: '' Second approach is better, because in this case pyplusplus will take into account all data available from baseB, but will not generate code. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From roman.yakovenko at gmail.com Wed Jul 26 21:06:33 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 26 Jul 2006 22:06:33 +0300 Subject: [C++-sig] Base class defined in other header file notincludedin bp::bases<> In-Reply-To: <5383A81D5EB8F14FBDB487D9B5FBEA88015C229E@NAEX11.na.qualcomm.com> References: <7465b6170607140134r5534654dtb54cec53cd930fa7@mail.gmail.com> <5383A81D5EB8F14FBDB487D9B5FBEA88015C229E@NAEX11.na.qualcomm.com> Message-ID: <7465b6170607261206q11304011rd6ec139c215c581e@mail.gmail.com> On 7/26/06, Haridev, Meghana wrote: > for c in baseB_creators: > > c.create = lambda self: '' ^^^^^^^^^^^^^^^^^^^^^ c.create = lambda: '' Please try this, it should work. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From mharidev at qualcomm.com Wed Jul 26 21:17:48 2006 From: mharidev at qualcomm.com (Haridev, Meghana) Date: Wed, 26 Jul 2006 12:17:48 -0700 Subject: [C++-sig] Base class defined in other header file notincludedinbp::bases<> In-Reply-To: <7465b6170607261206q11304011rd6ec139c215c581e@mail.gmail.com> Message-ID: <5383A81D5EB8F14FBDB487D9B5FBEA88015C22AB@NAEX11.na.qualcomm.com> Great - that works :-) Thanks for your help! -----Original Message----- From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Roman Yakovenko Sent: Wednesday, July 26, 2006 12:07 PM To: Development of Python/C++ integration Subject: Re: [C++-sig] Base class defined in other header file notincludedinbp::bases<> On 7/26/06, Haridev, Meghana wrote: > for c in baseB_creators: > > c.create = lambda self: '' ^^^^^^^^^^^^^^^^^^^^^ c.create = lambda: '' Please try this, it should work. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig From roman.yakovenko at gmail.com Wed Jul 26 21:22:42 2006 From: roman.yakovenko at gmail.com (Roman Yakovenko) Date: Wed, 26 Jul 2006 22:22:42 +0300 Subject: [C++-sig] Base class defined in other header file notincludedinbp::bases<> In-Reply-To: <5383A81D5EB8F14FBDB487D9B5FBEA88015C22AB@NAEX11.na.qualcomm.com> References: <7465b6170607261206q11304011rd6ec139c215c581e@mail.gmail.com> <5383A81D5EB8F14FBDB487D9B5FBEA88015C22AB@NAEX11.na.qualcomm.com> Message-ID: <7465b6170607261222v3825fd5auaf904898dbc6315b@mail.gmail.com> On 7/26/06, Haridev, Meghana wrote: > Great - that works :-) > Thanks for your help! Enjoy. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ From roberto.c.aguilar at gmail.com Thu Jul 27 00:17:31 2006 From: roberto.c.aguilar at gmail.com (Roberto Aguilar) Date: Wed, 26 Jul 2006 15:17:31 -0700 Subject: [C++-sig] Boost.Python to use non-standard python location on OS X Message-ID: Hello, I'm trying to build the example Boost.Python project on OS X using the python version 2.4.2 provided by Fink, which is installed at: /sw/bin/python The includes and libraries are: /sw/include/python2.4 /sw/lib/python2.4 I set the following in my Jamrules file: PYTHON_VERSION = 2.4 ; PYTHON_ROOT = /sw ; PYTHON_INCLUDES = /sw/include/python2.4 ; PYTHON_LIB_PATH = /sw/lib/python2.4 ; But, when I build, it seems that the resulting module is still linking to /usr/bin/python, which is version 2.3. Trying to use the module using /sw/bin/python results in: ---- [berto at drjekyll][713]$ /sw/bin/python Python 2.4.2 (#1, Mar 22 2006, 18:15:19) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import data Fatal Python error: Interpreter not initialized (version mismatch?) Abort trap ---- But using /usr/bin/python, everything works well. I then thought the problem was that I built boost without specifying the non-standard location so I recompiled using: ---- bjam -sTOOLS=darwin -sPYTHON_ROOT=/sw -sPYTHON_VERSION=2.4 -sPYTHON_INCLUDES=/sw/include/python2.4 -sPYTHON_LIB_PATH=/sw/lib/python2.4 -a ---- Still no luck. Any ideas are greatly appreciated. Thanks! -Roberto. From dave at boost-consulting.com Fri Jul 28 03:23:07 2006 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 27 Jul 2006 21:23:07 -0400 Subject: [C++-sig] Protected destructor compile error References: Message-ID: Daniel Wallin writes: > David Abrahams wrote: >> Did I mention I'm not making any heavy decisions while I'm on >> vacation? Why don't y'all discuss the tradeoffs here and decide >> whether it's worth it. > > I think the incompatibility problem makes the change not worth the > trouble. Well, in principle every version of Boost.Python produces incompatible extension modules. It just may be that some continue to work. The cost of a function pointer indirection is usually lost in the noise. > This issue isn't common enough. Introducing a metafunction that > can be specialized by the user OTOH is a really trivial change. I have > code ready with a "is_destructible" metafunction, shall I add tests and > check in? It's okay by me if you add docs too ;) -- Dave Abrahams Boost Consulting www.boost-consulting.com From dave at boost-consulting.com Fri Jul 28 03:24:49 2006 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 27 Jul 2006 21:24:49 -0400 Subject: [C++-sig] Boost.Python to use non-standard python location on OS X References: Message-ID: "Roberto Aguilar" writes: > I then thought the problem was that I built boost without specifying > the non-standard location That would certainly be a problem. > so I recompiled using: > > ---- > bjam -sTOOLS=darwin -sPYTHON_ROOT=/sw -sPYTHON_VERSION=2.4 > -sPYTHON_INCLUDES=/sw/include/python2.4 > -sPYTHON_LIB_PATH=/sw/lib/python2.4 -a > ---- > > Still no luck. > > Any ideas are greatly appreciated. Sorry, it sounds like you're on the right track, FWIW. -- Dave Abrahams Boost Consulting www.boost-consulting.com From eduardo.picado at gmail.com Fri Jul 28 15:27:43 2006 From: eduardo.picado at gmail.com (Eduardo Picado) Date: Fri, 28 Jul 2006 15:27:43 +0200 Subject: [C++-sig] boost python liking problems Message-ID: <6c75ff8f0607280627t1e86f90bicefbfd1344567fe3@mail.gmail.com> Hi, I'm trying to use Boost Python to wrap a 3rd party library. I have the headers, DLLs and a .lib file. When I try to compile my .cpp files I receive linkage errors: ------------- Creating library bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.lib and object bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.exp TASRNlSmlResult.obj : error LNK2001: unresolved external symbol "public: char const * __thiscall TASRNlSmlResult::str(void)const " (?str at TASRNlSmlResult@@QBEPBDXZ) ?....... "link" /nologo /INCREMENTAL:NO /DEBUG /DLL /subsystem:console /out:"bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.pyd" /IMPLIB:"bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.lib " /LIBPATH:"c:\python22\libs" /LIBPATH:"bin\boost\libs\python\build\boost_python.dll\msvc\debug\threading-multi" /LIBPATH:"C:\PROGRA~1\MICROS~4\VC98\lib" "boost_python.lib" @"bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.CMD" ...failed vc-Link bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.pyd bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.lib... ...failed updating 1 target... --------------- I'm using bjam with canonical options. I guess I'm not correcting specifying where is the .lib file. How can I do this? Any ideas? Thanks, Eduardo Picado From investtcartier at yahoo.com Fri Jul 28 19:25:04 2006 From: investtcartier at yahoo.com (Kevin Jones) Date: Fri, 28 Jul 2006 10:25:04 -0700 (PDT) Subject: [C++-sig] Converting a python dictionary rvalue to a T* in boost.python Message-ID: <20060728172504.66819.qmail@web55512.mail.re4.yahoo.com> Hi all, I have a c++ class T that implements an extended table. Additionally, I have a C++ function that takes a T* as an argument void (E.g. - f(T* t) ). How do I create converter to convert an arbitrary python dictionary in boost.python to a T* as an argument? The doucmentation is sparse and I have not found any comparable examples. Thanks in advance __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From dave at boost-consulting.com Fri Jul 28 20:44:20 2006 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 28 Jul 2006 14:44:20 -0400 Subject: [C++-sig] boost python liking problems References: <6c75ff8f0607280627t1e86f90bicefbfd1344567fe3@mail.gmail.com> Message-ID: "Eduardo Picado" writes: > I'm trying to use Boost Python to wrap a 3rd party library. I have the > headers, DLLs and a .lib file. > When I try to compile my .cpp files I receive linkage errors: Surely this is when you try to link your shared objects... > ------------- > Creating library > bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.lib > and object bin\telismaPyste\TASRNlSmlResult.pyd\msvc\debug\threading-multi\TASRNlSmlResult.exp > TASRNlSmlResult.obj : error LNK2001: unresolved external symbol > "public: char const * __thiscall TASRNlSmlResult::str(void)const " > (?str at TASRNlSmlResult@@QBEPBDXZ) Are you sure you didn't just forget to define the member function TASRNlSmlResult::str() const as denoted in the error message? The message gives the impression that it's supposed to be part of your code. If not, extension TASRNlSmlResult : # sources whatever.cpp # requirements and dependencies for Boost.Python extensions