tag:blogger.com,1999:blog-7021667619473970091.post4753959127249622364..comments2023-11-03T04:49:37.254-07:00Comments on Adventures in Perl: Interfacing Perl with C++, using XS, with external files, and using the STL as parameters and return values.Ryan Dietrich (dextius)http://www.blogger.com/profile/11943821568720043413noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-7021667619473970091.post-45396782138456799362011-06-24T12:01:19.850-07:002011-06-24T12:01:19.850-07:00I know this is a super, super late comment, but pl...I know this is a super, super late comment, but please take a look at ExtUtils::XSpp for using C++ from Perl. I also presented on this at YAPC: http://steffen-mueller.net/talks/xspp/Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-36125398146037615252010-09-08T02:12:03.833-07:002010-09-08T02:12:03.833-07:00I was able to define multiple objects in an XS fil...I was able to define multiple objects in an XS file ... sort of. If u do not declare the constructor of the other class and just declare methods u will use from that class it will work just fine. I don't need a constructor as the main class has a method that returns on object of that other class. So as a workaround you can make your main class have methods that construct other kind of objects for you.Unknownhttps://www.blogger.com/profile/00714918855282903781noreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-38144309901063448412010-08-12T11:19:39.132-07:002010-08-12T11:19:39.132-07:00Sorry about that Sparticus! I fixed it! Make sur...Sorry about that Sparticus! I fixed it! Make sure your tab indents are correct when you type in the Makefile code!Ryan Dietrich (dextius)https://www.blogger.com/profile/11943821568720043413noreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-21501744897948999952010-08-10T21:54:18.191-07:002010-08-10T21:54:18.191-07:00SimpleTest/SimpleLib/Makefile.PL and SimpleTest/Ma...SimpleTest/SimpleLib/Makefile.PL and SimpleTest/Makefile.PL are currently identical. You'll need to adjust the paths, etc. in SimpleTest/SimpleLib/Makefile.PL, in order for this to actually work. Additionally, 'make bin' returns an error: make: *** No rule to make target `bin'. Stop.Michaelhttps://www.blogger.com/profile/07901684157461291871noreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-36280682273797022672010-08-10T21:51:18.836-07:002010-08-10T21:51:18.836-07:00This comment has been removed by the author.Michaelhttps://www.blogger.com/profile/07901684157461291871noreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-51384723976621357492010-08-10T16:03:16.252-07:002010-08-10T16:03:16.252-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-46506611227721116322010-08-05T10:45:57.908-07:002010-08-05T10:45:57.908-07:00Hey Ryan,
You're welcome. I've struggled ...Hey Ryan,<br /><br />You're welcome. I've struggled with it for a while but I am nowhere near the amount of knowledge you've gathered in this pursuit. Due to my lack of C++ knowledge, I don't even really have a clue what a typemap is. I know it's there to do the value transformation between the Perl side and the C/C++ side. But as to how it works, or what they mean, no idea.<br /><br />I don't believe p5p actually went off their path with this. I'm quite certain from what I see from CPAN that XS is a very powerful, low-level system. And I think making sure the low-level is there is what is actual in p5p's best interest, since a flexible lower level allows for more powerful higher levels. Perls built in OO System is very raw, and rather low-level. But it allowed some very bright people to come up with Moose, and to form a community around it. I think what's missing is not really a better way, but better documentation of the way, so a higher level can take care of things. This is not a complaint regarding XS or the people who work in this regard. The work that's done and the possibilities it creates are amazing, and writing tutorials, cookbooks and other resources would probably not be number one on my priority list either.<br /><br />As you said, it is intrinsic, but I fear it is not all that simple. And my guess is that there's not enough levels of abstraction thrown at the problem.<br /><br />Because if we look around, C++ class integration seems to be a hard job with many dynamic languages. I know of a project integrating boost and Python, but I'm not in the position to judge how that works out. Other than that, I can only think of Chicken Scheme that has a C/C++ interface. But then again, it compiles down to C. There might be more that I'm simply not aware of because I didn't look that hard :)phaylonhttps://www.blogger.com/profile/12032005649016985100noreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-66473304713303217032010-08-05T10:14:31.393-07:002010-08-05T10:14:31.393-07:00Robert, thank you. Just hearing someone say somet...Robert, thank you. Just hearing someone say something nice after pouring all this out of me was very thoughtful of you. Hopefully Parrot will make this easier when the times come.<br /><br />Obviously, I'm nowhere near the "insiders" on the perl5-porters lists. I've read them from afar, these guys are mind blowingly smart. <br /><br />Still, it's hard to believe they'd ditch their mantra "make the simple things simple, and the hard things possible" when it comes to something so intrinsic to development (interfacing with external languages).Ryan Dietrich (dextius)https://www.blogger.com/profile/11943821568720043413noreply@blogger.comtag:blogger.com,1999:blog-7021667619473970091.post-18341630931841334782010-08-05T09:35:08.143-07:002010-08-05T09:35:08.143-07:00As a non C/C++ developer who tried multiple times ...As a non C/C++ developer who tried multiple times to use complex shared libraries either in C or C++ I feel your pain. I tried (and gave up) multiple times to integrate C++ classes by using an interfacial Moose class to introspect for the specification. The main part that seems to make it ugly is that C/C++ are quite hard to parse themselves. Header files seem to be more of a convention than anything enforced. Even the gcc-xml project gave me only a short span of hope.<br /><br />When i gave up on the inspection part and went for declaring the full interface in the meta objects of the classes, I ran into a wall trying to couple C++ to Perl via XS with my little knowledge of the first. I'm still not even sure how extendable classes are from the Perl side when they were integrated via XS. Does it work to pass an extended subclass to the library? I don't know.<br /><br />I think there's a certain disconnect between two camps, but I'm not sure what exactly those camps are. Maybe the one side is the "inside-Perl" enthusiasts who want a simple but complete binding, and do lots of logic in Perl; while the other side is very fluent in C++ and prefers to do it on that side and use XS to link stuff in. I could imagine that the know how to build a foreign class interface to C++ is available in the community as a whole, but that no overlappings of the different interests have yet reached critical mass.phaylonhttps://www.blogger.com/profile/12032005649016985100noreply@blogger.com