20 Dec 2011 19:39
Differences between C++ Cython wrapper and C++ program
Dag Sverre Seljebotn <d.s.seljebotn <at> astro.uio.no>
2011-12-20 18:39:06 GMT
2011-12-20 18:39:06 GMT
Hi list, I'm trying to wrap a proprietary, closed-source C++ library using Cython. The library essentially fails to work when used through a Cython wrapper, but works when compiling as a standalone executable with the same compiler flags. I.e., I have a function "foomain" with some C++ code which attempts to make a certain network connection. If I call foomain() from main() in a C++ program, things work. If I call foomain() from Cython, compiled in C++ mode, then things don't work (no connection is made). So what are the possible differences in the runtime environment you can think of? The first thing I had to do was this: import sys, ctypes sys.setdlopenflags(sys.getdlopenflags()|ctypes.RTLD_GLOBAL) This fixed something else (a function mysteriously returning a NULL pointer when it shouldn't -- as I don't have the sources I don't know why, really). But apparently it didn't fix everything. I've tried both with and without creating a thread using the threading module (so that a GIL is set up), and both with and without "with nogil" around the call to foomain(). Dag Sverre(Continue reading)
RSS Feed