Hey again guys. I'm wondering if it's possible to compile python/cython code as a static lib and reuse it from python/cython?
I've exhausted questions/answers from this group, cython docs, SO and Google to the best of my ability.
So far (over the past couple of years) I've gotten everything else involving Cython except using cython static libs to work:
* Compiling to and reusing python/cython code from shared libs
* Pure C/C++ using extern from
* Compiling and reusing pure C/C++ code from a static lib using extern from
* "Including" and embedding a large codebase as a cython standalone
Things I've tried to reuse cython code from static lib:
* cdef extern void test()
* cdef extern from "cythonlib.h":
void test()
* cimport cythonlib
* include "cythonlib.pxd"
* include "cythonlib.pyx"
The error I get with extern/extern from is: /usr/bin/ld: /tmp/ccaKkuJb.o: in function `__pyx_pymod_exec_run(_object*)':
run.cpp:(.text+0x8d4): undefined reference to `test()'
The only thing that's worked for me as I said is rewriting as pure C++ and linking to this cpplib.a:
run.pyx:
cdef extern from "cpplib.h":
void test()
test()
If I use this same run.pyx file/definition/content as above but link to cythonlib.a instead (same signature, just Cython vs pure C++ code) I get the same error as above.
PS: I highly avoid using distutils due to its clunkiness, so a general answer/explanation or one using binutils is highly preferred if possible.