<div dir="ltr">Not exactly: if you build numpy with mingw (as is the official binary), you need to build everything that uses numpy C API with it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 26, 2014 at 1:22 AM, Matthew Brett <span dir="ltr"><<a href="mailto:matthew.brett@gmail.com" target="_blank">matthew.brett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sat, Oct 25, 2014 at 2:15 PM, Matthew Brett <<a href="mailto:matthew.brett@gmail.com">matthew.brett@gmail.com</a>> wrote:<br>
> On Fri, Oct 24, 2014 at 6:04 PM, Matthew Brett <<a href="mailto:matthew.brett@gmail.com">matthew.brett@gmail.com</a>> wrote:<br>
>> Hi,<br>
>><br>
>> We (dipy developers) have a hit a new problem trying to use the<br>
>> ``npy_log`` C function in our code.<br>
>><br>
>> Specifically, on Linux, but not on Mac or Windows, we are getting<br>
>> errors of form:<br>
>><br>
>> ImportError: /path/to/extension/<a href="http://distances.cpython-34m.so" target="_blank">distances.cpython-34m.so</a>: undefined<br>
>> symbol: npy_log2<br>
>><br>
>> when compiling something like:<br>
>><br>
>> <eg_log.pyx><br>
>> import numpy as np<br>
>> cimport numpy as cnp<br>
>><br>
>> cdef extern from "numpy/npy_math.h" nogil:<br>
>>     double npy_log(double x)<br>
>><br>
>><br>
>> def use_log(double val):<br>
>>     return npy_log(val)<br>
>> </eg_log.pyx><br>
>><br>
>> See : <a href="https://github.com/matthew-brett/mincy/tree/npy_log_example" target="_blank">https://github.com/matthew-brett/mincy/tree/npy_log_example</a> for<br>
>> a self-contained example that replicates the failure with ``make``.<br>
>><br>
>> I guess this means that the code referred to by ``npy_log`` is not on<br>
>> the ordinary runtime path on Linux?<br>
><br>
> To answer my own question - npy_log is defined in ``libnpymath.a``, in<br>
> <numpy>/core/lib.<br>
><br>
> The hint I needed was in<br>
> <a href="https://github.com/numpy/numpy/blob/master/doc/source/reference/c-api.coremath.rst" target="_blank">https://github.com/numpy/numpy/blob/master/doc/source/reference/c-api.coremath.rst</a><br>
><br>
> The correct setup.py is:<br>
><br>
> <setup.py><br>
> from distutils.core import setup<br>
> from distutils.extension import Extension<br>
> from Cython.Distutils import build_ext<br>
><br>
> from numpy.distutils.misc_util import get_info<br>
> npm_info = get_info('npymath')<br>
><br>
> ext_modules = [Extension("eg_log", ["eg_log.pyx"],<br>
>                          **npm_info)]<br>
><br>
> setup(<br>
>   name = 'eg_log',<br>
>   cmdclass = {'build_ext': build_ext},<br>
>   ext_modules = ext_modules<br>
> )<br>
> </setup.py><br>
<br>
</div></div>Ah, except this doesn't work on Windows, compiling with Visual Studio:<br>
<br>
LINK : fatal error LNK1181: cannot open input file 'npymath.lib'<br>
<br>
Investigating, c:\Python27\Lib\site-packages\numpy\core\lib has only<br>
`libnpymath.a``; I guess this isn't going to work for Visual Studio.<br>
Is this a bug?<br>
<div class="HOEnZb"><div class="h5"><br>
Cheers,<br>
<br>
Matthew<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div>