On Wed, Nov 11, 2009 at 8:05 PM, J. Jankins <[email protected]>wrote:
>
> Hello,
>
> I am trying to use C++ STL, specifically container <vector> and <set>. But
> I just find a little discription in <Cython Manual>. And I couldn't even to
> get the example to work.
>
> Here is what I do:
> 1. <stl.h>:
> #include <vector>
>
> 2. <pstl.pyx>:
> cdef extern from "stl.h":
> ctypedef struct intvec "std::vector<int>":
> void (* push_back) (int elem)
> intvec intvec_factory "std::vector<int>" (int len)
>
> def main():
> cdef intvec v = intvec_factory(2)
> v.push_back(3)
> print 'Hello'
>
> 3.<setup.py>:
> from distutils.core import setup
> from distutils.extension import Extension
> from Cython.Distutils import build_ext
>
> setup(
> name = 'Demos',
> ext_modules=[
> Extension("test",
> sources=["pstl.pyx"],
> include_dirs=["."],
> language="c++"),
> ],
> cmdclass = {'build_ext': build_ext},
> )
>
> 4. python setup.py build_ext --inplace
>
> When I import "pstl", there is an ImportError.
>
> I am totally frustrated. And I commit that: I didn't finish reading Cython
> Manual. It's not that easy to understand and it has too few examples.
>
> Thanks.
>
> Jankins
>
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
>
This has nothing to do with Cython, but with a bug your setup.py (your
extension have to be name "pstl" instead of "test"). Please read distutils
documentation; hopefuly, it will be easier to understand and will show many
more examples compared to Cython docs.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
<<spacer.gif>>
_______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
