--
---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Using a single C library is what I'm doing,and the problem is how to dynamically link the C library. If statically linked, each extension module will have a independent pool itself.
The problem exists for cdef way, too. So the problem is not how to code it, but how to build it.
Sorry, I confused your cdef method with cdef extern. I have tried wrapping and it works.I have written all features by pure Python beforehead, but found it too slow, and cost too much memory. So I implemented some of the Python classes by C++, and wrapped them by Cython, while keep the Python interface unchanged. Each of the classes has a .h, a .cpp, a .pyd and a .pyx files. The C++ interface and Python interface are both declared in the pyd file. The pyx files are compiled together with its corresponding cpp file.However, to improve the speed, some C++ methods are also called directly from other cpp files and pyx files. When compiling, the linker complains about unresolved symbols, so I added the corresponding cpp file to sources for each of the pyx files. As a result, one cpp file is compiled multiple times and each compiled extension have a independent pool.
Writing cdef wrappers means extra work, and won't solve the problems caused by calling C++ methods from another cpp files, so I think it would be better for me to just compile all hand-written cpp files to a dynamic library and link it against all pyx files.
I didn't know how to generate a dynamic library by distutils on Windows and found few results when googling. Is there a better/standard way to build shared library by setuptools?
I agree a shared, dynamically linked library is the right solution to this problem.I didn't know how to generate a dynamic library by distutils on Windows and found few results when googling. Is there a better/standard way to build shared library by setuptools?
but we did not find a way for setuptools to build the dll (or so on *nix) -- we simply build that extenally.
here is our build script -- pretty ugly and complex, but maybe you can tease out what you need.
As far as I can see, a pyd, which is actually a dll, is built from all the cpp files and basic_types_ext.pyx.
On windows, basic_types_ext do not need to be imported. When importing other modules, with the help of the import library, basic_types_ext.pyd will be loaded as a dll.
I'm not sure if it should be imported before any other extension module on Linux/Mac OSX.Since I do not have that much external libraries, this method has fewer platform-dependent code than using distutils.ccompiler.
I'm using Python 3.5 and VS2015. The generated lib file's name is module.cp35-win_amd64.lib, with platform informations in the filename. Everything else is just as expected.
--
---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.