将英特尔的MKL(BLAS&LAPACK)连接到GCC

Linking Intel's MKL (BLAS & LAPACK) to GCC

本文关键字:LAPACK 连接 GCC BLAS 英特尔 MKL      更新时间:2023-10-16

我正在尝试编译一个巨大的软件包,而这似乎是我无法解决的最后一个障碍。

我得到如下错误:

RNDiracDeterminantBase.cpp:(.text+0x22bf): undefined reference to `dgetrf_'
RNDiracDeterminantBase.cpp:(.text+0x2524): undefined reference to `dgetri_'
RNDiracDeterminantBase.cpp:(.text+0x3005): undefined reference to `dgetri_'
../../lib/libqmcwfs.a(RNDiracDeterminantBase.cpp.o): In function `qmcplusplus::RNDiracDeterminantBase::ratio(qmcplusplus::ParticleSet&, int, qmcplusplus::ParticleAttrib<qmcplusplus::TinyVector<double, 3u> >&, qmcplusplus::ParticleAttrib<double>&)':
RNDiracDeterminantBase.cpp:(.text+0x4156): undefined reference to `dgemv_'
RNDiracDeterminantBase.cpp:(.text+0x420f): undefined reference to `dger_'

Google透露,这些引用是英特尔的MKL库。但是,我不知道我需要链接什么文件。我试过libmkl_core。libmkl_gnu_thread。libmkl_blacs_intelmpi_lp64。一个,等等。

里面有很多文件

/mkl/lib/intel64/

可以根据需要发布更多信息

我不知道我需要链接什么文件。我试过libmkl_core。libmkl_gnu_thread。libmkl_blacs_intelmpi_lp64。一个,等等。在:/mkl/lib/intel64/

中有大量的文件

事实上有大量的文件并不意味着你必须依次尝试每个库。

要找出哪个库定义了你想要的符号,运行这个命令:

cd /mkl/lib/intel64
nm -A *.a | egrep '[TWBD] (dger_|dgemv_|dgetrf_|dgetri_)$'

还要确保将库放在链接行的末尾,因为命令行上归档库的顺序很重要。

根据您提供的不完整信息,您很可能需要libmkl_intel_lp64。libmkl_gnu_thread。A和libmkl_core.a。

英特尔MKL有一个内置的工具来帮助你找出链接:/MKL/tools/mkl_link_tool。这个工具也可以在网站上找到:http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor。使用此工具可以根据您的情况获得确切的链接行。

你应该在MKL官方论坛(http://software.intel.com/en-us/forums/intel-math-kernel-library)上提出你的问题。你可以在几小时内得到这类问题的答案,而不是几天。

我在windows上设置mingw时遇到了类似的问题。

下面的库链接顺序为我工作与gcc:

  1. mkl_intel_thread
  2. mkl_rt
  3. mkl_core
  4. mkl_intel_lp64