Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6590 Discussions

NumPy ImportError: undefined symbol: ownLastTriangle_64fc


I'm running Ubuntu 13.04, and have the latest versions of the MKL, icc, and ifort. I'm trying to build NumPy 1.8.0beta2 and have been running into an unusual error. The package builds and installs just fine, but when I run "import numpy as np" in the Python 3.3.2 (gcc-built) interpreter, I get the following traceback:


>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.3/site-packages/numpy/", line 153, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python3.3/site-packages/numpy/", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python3.3/site-packages/numpy/lib/", line 18, in <module>
    from .polynomial import *
  File "/usr/local/lib/python3.3/site-packages/numpy/lib/", line 19, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/usr/local/lib/python3.3/site-packages/numpy/linalg/", line 50, in <module>
    from .linalg import *
  File "/usr/local/lib/python3.3/site-packages/numpy/linalg/", line 29, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: /opt/intel/mkl/lib/intel64/ undefined symbol: ownLastTriangle_64fc


My site.cfg is as follows:


library_dirs = /opt/intel/lib:/opt/intel/lib/intel64:/opt/intel/mkl/lib:/opt/intel/mkl/lib/intel64:/usr/local/lib/python3.3
include_dirs = /opt/intel/include/intel64:/opt/intel/include:/opt/intel/mkl/include:/opt/intel/mkl/include/intel64/lp64:/usr/local/include/python3.3m

library_dirs = /opt/intel/lib:/opt/intel/lib/intel64:/opt/intel/mkl/lib:/opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/include/intel64:/opt/intel/include:/opt/intel/mkl/include:/opt/intel/mkl/include/intel64/lp64
mkl_libs = mkl_rt,mkl_intel_lp64,mkl_intel_thread,mkl_core,mkl_def,mkl_avx,mkl_vml_def,mkl_lapack95_lp64,mkl_blas95_lp64
lapack_libs = mkl_lapack95_lp64
blas_libs = mkl_blas95_lp64

library_dirs = /opt/intel/lib:/opt/intel/lib/intel64:/opt/intel/mkl/lib:/opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/include/intel64:/opt/intel/include:/opt/intel/mkl/include:/opt/intel/mkl/include/intel64/lp64
blas_libs = mkl_blas95_lp64

library_dirs = /opt/intel/lib:/opt/intel/lib/intel64:/opt/intel/mkl/lib:/opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/include/intel64:/opt/intel/include:/opt/intel/mkl/include:/opt/intel/mkl/include/intel64/lp64
lapack_libs = mkl_lapack95_lp64

If I just use mkl_libs = mkl_rt I get an error complaining that libmkl_avx and libmkl_def can't be found, and if I just have those three I get the same error as I'm getting now.

I changed numpy/distutils/ to have the following:


self.cc_exe = 'icc -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -mkl -m64 -DMKL_LP64 -L/opt/intel/lib -L/opt/intel/lib/intel64 -L/opt/intel/mkl/lib -L/opt/intel/mkl/lib/intel64 -L/usr/local/lib/python3.3 -I/opt/intel/include/intel64 -I/opt/intel/include -I/opt/intel/mkl/include -I/opt/intel/mkl/include/intel64/lp64 -I/usr/local/include/python3.3m'


and I changed numpy/distutils/fcompiler/ in similar fashion:


def get_flags_opt(self):
    return [' -O3 -mkl -xhost -openmp -fp-model strict -fPIC -m64 -DMKL_LP64 -L/opt/intel/lib -L/opt/intel/lib/intel64 -L/opt/intel/mkl/lib -L/opt/intel/mkl/lib/intel64 -L/usr/local/lib/python3.3 -I/opt/intel/include/intel64 -I/opt/intel/include -I/opt/intel/mkl/include -I/opt/intel/mkl/include/intel64/lp64 -I/usr/local/include/python3.3m']


Finally, I commented out lines 953-956 in numpy/distutils/ where the pthread library is automatically added, as I want to use Intel's threading library included in the MKL.

I googled the error I'm getting, and there were literally zero hits. I'm not sure where this symbol is defined, so I don't know how to link to the required library. Can anyone offer any assistance?



0 Kudos
7 Replies

Hi, have you taken a look at this article?

This article walks through everything and will probably anticipate future issues as well. Another good link to bookmark is the link line advisor which is always a good tool for general build and run:

Take a look at the NumPy article, go through all those steps and let me know how it shakes out. From there we will have a baseline to rule out many different issues.



The article you referenced has recently been updated for the latest NumPy and MKL releases. But it only covers the situation of using Intel tool chain (Intel compiler and Intel OpenMP threading). You are using GNU compilers and GNU OpenMP. So we need some more investigation.

Please post your 'site.cfg', as well as your compiler configuration files (the relevant ones found under the distutil directory of the NumPy source).





That article is quite a bit dated for Intel MKL and even NumPy. I just ran into the same issue above where Intel MKL is having undefined references to the ownLastTriagle_64fc. Confirming against the shared library:


$ nm | grep ownLastTriangle_64fc

U ownLastTriangle_64fc


Although I am using the GNU compilers (gcc,g++,gfortran) for this particular build of NumPy. The line to compile essentially looks as:

[bash]gcc -m64 -mavx -march=native -mtune=native -fopenmp -I${MKLROOT}/include ...[/bash]

The link like would look something like the following:

[bash]gcc -L${MKLROOT}/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_avx -lmkl_def -ldl -lpthread -lm -Wl,-rpath,${MKLROOT}/lib/intel64 ...[/bash]

The previous link line which I recieved the error earlier was like:

[bash] gcc -L${MKLROOT}/lib/intel -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm -Wl,-rpath,${MKLROOT}/lib/intel64 ...[\bash]

works during the import, but then actually starting a test with NumPy, MKL issues a fatal error:

Python 2.7.6 (default, Mar 6 2014, 09:13:15)

>>>import numpy 
>>> numpy.test() 
Running unit tests for numpy NumPy version 1.8.0 NumPy is installed in /apps/python/gnu/2.7.6/lib/python2.7/site-packages/numpy Python version 2.7.6 (default, Mar 6 2014, 09:13:15) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] nose version 1.3.0 ................. 
Intel MKL FATAL ERROR: Cannot load or

Which is why I lead to the method of adding and to the link line and then get the undefined reference. I didn't have this problem when I was using MKL 10.3, only when I started moving code to MKL 11 It appears that the string can be located in the files following:

$ grep ownLastTriangle_64fc *

Binary file matches 
Binary file matches 
Binary file libmkl_core.a matches 
Binary file matches 
Binary file matches 
Binary file matches 
Binary file matches

Changing the link line to use the single runtime library ( issues the same MKL FATAL ERROR.

Have any ideas where to go from here?



library_dirs = /lib64:/usr/lib64:/usr/local/lib
include_dirs = /usr/include:/usr/local/include
libraries = dl, pthread, m

library_dirs = /apps/INTEL/2013/mkl/lib/intel64
include_dirs = /apps/INTEL/2013/mkl/include
mkl_libs = mkl_gf_lp64, mkl_gnu_thread, mkl_core
lapack_libs = 

The compiler happens as the following, I don't necessarily modify the files under distutil directory. I just append certain flags using the environment variables here. The compiler files under distutils are unchanged. I prefer this method rather than editing the *.py files.

export CPPFLAGS="-I$MKLROOT/include"
export CFLAGS="-mavx -m64 -fopenmp -march=native -mtune=native -O3 -fPIC -fomit-frame-pointer"
export CXXFLAGS="-mavx -m64 -fopenmp -march=native -mtune=native -O3 -fPIC -fomit-frame-pointer"
export FFLAGS="-mavx -m64 -fopenmp -march=native -mtune=native -O3 -fPIC -fomit-frame-pointer"
export LDFLAGS="-fopenmp -L$MKLROOT/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm -Wl,-rpath,$MKLROOT/lib/intel64"

python config
python build
python install


Then when I try to run the numpy test after the build:

Python 2.7.6 (default, Mar  6 2014, 09:13:15) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.test()
Running unit tests for numpy
NumPy version 1.8.0
NumPy is installed in /apps/python/gnu/2.7.6/lib/python2.7/site-packages/numpy
Python version 2.7.6 (default, Mar  6 2014, 09:13:15) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
nose version 1.3.0
Intel MKL FATAL ERROR: Cannot load or


I make sure I sanitize the NumPy build each time a make a change as well.



Jared, I don't think that :

gcc -L${MKLROOT}/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_avx -lmkl_def -ldl -lpthread -lm -Wl,-rpath,${MKLROOT}/lib/intel64 ...

is correct, but this should be ok:

gcc -L${MKLROOT}/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm -Wl,-rpath,${MKLROOT}/lib/intel64 ...

And, as far as I know, the issue at runtime with numpy is still not solved with Mkl-

Any progress from Intel side ?



The page now has a section "Building with GNU Compiler chain" at the bottom that says to only specify mkl_rt for mkl_libs in site.cfg.

I tried this after running into the same problem being reported here, and it resolved the issue for me (using GCC 4.8.3, imkl and numpy 1.8.0).


I encountered the same error after I removed a remaining .so file from a previous installation of numpy (/usr/local/lib/python3.7/site-packages/numpy/.libs/ Similar to the suggestion at:

I added mkl_def in site.cfg of numpy.