On Tue, Sep 20, 2011 at 8:38 AM, Sean Poust <po...@berkeley.edu> wrote:

> I keep getting this error: #warning "Using deprecated NumPy
> API, disable it by #defining NPY_NO_DEPRECATED_API" and a bunch of
> undefined variables when comping cython code with numpy
>

This is a warning introduced in current NumPy master. It's just a warning,
so it's not the cause of the errors.


>
> I am new to cython and numpy and I am having trouble getting a *.pyx
> extension
> to compile with this in the header:
>
> from __future__ import division
> import numpy as np
> cimport numpy as np
> DTYPE = np.int
> ctypedef np.int_t DTYPE_t
>
> I complie to C code using:
> cython -a montcarl.pyx
>
> And it seems to work fine.
>
> I then attempt to compile using:
>
> gcc -I /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/
> Python.framework/Versions/2.6/include/python2.6 -I /usr/local/lib/
> python2.7/site-packages/numpy/core/include -shared -pthread -fPIC -
> fwrapv -O2 -fno-strict-aliasing
> -o montcar.so montcarl.c
>
> And I get a bunch of undefined variables:
>
> spoust-m:old spoust$ gcc $CFLAGS -o montcar.so montcarl.c
> In file included from /usr/local/lib/python2.7/site-packages/numpy/
> core/include/numpy/ndarraytypes.h:1965,
>                from /usr/local/lib/python2.7/site-packages/numpy/
> core/include/numpy/ndarrayobject.h:17,
>                from /usr/local/lib/python2.7/site-packages/numpy/
> core/include/numpy/arrayobject.h:14,
>                from montcarl.c:225:
> /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy/
> npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy
> API, disable it by #defining NPY_NO_DEPRECATED_API"
> Undefined symbols:
>  "_PyLong_AsLong", referenced from:
>     ___Pyx_PyInt_AsLong in ccvkIDLQ.o
>     ___Pyx_PyInt_AsLong in ccvkIDLQ.o
> ...
>
> Any ideas on how to get this to compile and how to get rid of these
> numpy undefined variables? The cython guys directed me here.
>

PyLong_AsLong is a CPython API call:

http://docs.python.org/c-api/long.html#PyLong_AsLong

Looks like it's a problem linking with CPython, nothing to do with NumPy. I
would recommend looking at the Python version numbers of all the parts in
your build command line, I'm pretty sure that's where you will find your
problem. ;)

-Mark


>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to