[Numpy-discussion] npy_log2 undefined on Linux

Matthew Brett matthew.brett at gmail.com
Sat Oct 25 17:15:05 EDT 2014

On Fri, Oct 24, 2014 at 6:04 PM, Matthew Brett <matthew.brett at 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

The hint I needed was in

The correct setup.py is:

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"],

  name = 'eg_log',
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules



More information about the NumPy-Discussion mailing list