Arg... I really need a simple working example of C++ from a python module with a reasonable and simple setup.py. Why does that seem too much to ask?
http://paste.lisp.org/display/98607
Updated 2010-May-01:
Asked and answered here: Frustration with C++ and Python. May have also stumbled onto a gcc 4.4.2 bug that added to my confusion.
Friday, April 30, 2010
Subscribe to:
Post Comments (Atom)
Kurt, here's an example of a Python C extension module using a C++ library:
ReplyDeletehttp://trac.gispython.org/lab/browser/Rtree/tags/rel-0.4/rtree
In a nutshell, there's a thin C wrapper for the C++ code, and the C Python extension code uses the wrapper functions. It worked pretty well. Over time Howard Butler added a C API to the spatialindex lib and Rtree now accesses it using ctypes without any C extension code.
Sean, Thanks for the pointer! Turns out I basically was doing the right thing, but got bit by 32 vrs 64 bit code. gcc on the Mac defaults to 64 bit code, but I was using the 32bit tree of fink w/ python. Lesson here is that I should only code when I've had enough sleep to really read error messages. And after writing almost exclusively python for a few years, I had forgotten about null terminated lists.
ReplyDeleteHats off to the people who read my blog and help out. #python on IRC -- for just being annoying... but now I know how to authenticate myself to irc.freenode.net (aka... useless knowledge).