0

I have a question regarding the use of Armadillo with MKL. Now I have a program written in c++ using Armadillo library. In my computer, I have MKL (can be viewed as the replacement of lapack and blas) installed and I believe Armadillo had detected the MKL when the Armadillo was installed. Now I wrapped the c++ code in python via cython. But when I imported the module, I got the following error: "undefined symbol : dgesvx_". I searched the Internet and found that dgesvx is related to lapack library. Probably I missed something about the linking, but cannot figure it out. Can someone give me some advice? Thanks.

Here is the my setup.py for wrapping c++.

setup(name='example',
      version='0.1',
      packages=['example'],
      package_dir={'example': 'example'},
      description='Wrapper to Armadillo',
      #package_data={'cyarma': ['*.pyx','*.pxd']},
      cmdclass = {'build_ext': build_ext},
      ext_modules = [Extension("example",
                               ["example/example.pyx", "example/Test.cpp"],
                               include_dirs = [get_include(), '/usr/include',
                                               '/usr/local/include',
                                               cyarma.include_dir,
                                               "/Users/armadillo-9.900.1/include"],
                               library_dirs = ['/usr/lib', '/usr/local/lib/include"],
                               extra_compile_args = ['-lmkl']
                               language='c++',
                           ),
                 ]
      )

It worked fine on my another computer with lapack and blas installed.

Qiuyu Gu
  • 3
  • 2
  • It is not easy to say what is the problem. This answer of mine is kind of a tutorial how to trouble-shoot usage of so-files in extensions: https://stackoverflow.com/a/45655654/5769463. In this answer I actually link against mkl (it uses %%cython-magic, but the parameter can be easily translated to setup-arguments): https://stackoverflow.com/a/56922359/5769463. – ead Jun 17 '20 at 19:06
  • What looks strange to me: `-lmkl` should not be a compiler args, but `libraries = ["mkl"]`. `library_dirs` should have a path to mkl-libraries. I would also use runtime_library_dirs=[]. I'm not sure there is a mkl-library. I always assumed it is `mkl_rt` or something similar. – ead Jun 17 '20 at 19:11
  • Thank you so much. It looks like there is something wrong with the installation of Armadillo, since I do not have the access to the root. – Qiuyu Gu Jun 18 '20 at 01:02
  • 1
    using -mkl option will be recognized by Intel Compiler only. You need to link against mkl_rt as was mentioned above. – Gennady.F Jun 18 '20 at 04:58
  • Thanks for pointing that out! – Qiuyu Gu Jun 19 '20 at 12:50

0 Answers0