On Fri, Oct 24, 2014 at 6:04 PM, Matthew Brett <matthew.br...@gmail.com> wrote: > Hi, > > We (dipy developers) have a hit a new problem trying to use the > ``npy_log`` C function in our code. > > Specifically, on Linux, but not on Mac or Windows, we are getting > errors of form: > > ImportError: /path/to/extension/distances.cpython-34m.so: undefined > symbol: npy_log2 > > when compiling something like: > > <eg_log.pyx> > import numpy as np > cimport numpy as cnp > > cdef extern from "numpy/npy_math.h" nogil: > double npy_log(double x) > > > def use_log(double val): > return npy_log(val) > </eg_log.pyx> > > See : https://github.com/matthew-brett/mincy/tree/npy_log_example for > a self-contained example that replicates the failure with ``make``. > > I guess this means that the code referred to by ``npy_log`` is not on > the ordinary runtime path on Linux?
To answer my own question - npy_log is defined in ``libnpymath.a``, in <numpy>/core/lib. The hint I needed was in https://github.com/numpy/numpy/blob/master/doc/source/reference/c-api.coremath.rst The correct setup.py is: <setup.py> from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext from numpy.distutils.misc_util import get_info npm_info = get_info('npymath') ext_modules = [Extension("eg_log", ["eg_log.pyx"], **npm_info)] setup( name = 'eg_log', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules ) </setup.py> Cheers, Matthew _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion