LAPACK 与 gcc 启动指南
我需要帮助在 Linux gcc 中设置 LAPACK。我是 LAPACK 的新手,不了解使用 Fortran 的知识。
我已经下载了lapack-3.4.0,并制作了库来获取 liblapack.a 和 librefblas.a。
之后,我将这些库链接到我的程序: -llapack -lrefblas
我想使用 LAPACK 函数,如 dpotrf、dgetrf、dgetri 等, 如何包含头文件以便编译器找到这些函数?我是否有必要使用 lapacke(LAPACK 的 C 接口)?
I need help to setup LAPACK in Linux gcc. I am new to LAPACK and have no knowledge in using Fortran.
I have downloaded lapack-3.4.0, and make the libraries to get
liblapack.a and librefblas.a.
Afterwards, i link these libraries to my program:
-llapack -lrefblas
I wanted to use the LAPACK functions like dpotrf, dgetrf, dgetri etc,
How do I include the header files in order for my compiler to find the functions? Is it neccessary for me to use lapacke, a C interface to LAPACK?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 LAPACK 与 C++ 结合使用的方法有多种。这就是我要做的(假设您使用的是 *nix 系统)。
确保您拥有正确的库并且了解正确的编译器/链接器选项集。由于这些是用 Fortran 编写的,所以我将从 Fortran 代码开始。就像这个。确保您可以使用
gfortran
编译它。可能的链接器选项可以是(取决于您的系统):-llapack
、-lblas
或这些的某些组合。然后继续使用 C++ 界面。同样,有多种方法可以实现。我个人发现使用 clapack 接口是最简单的,您可以在其中声明 LAPACk 函数,如下所示:
所示: extern "C" void dsyev_( char *jobz, char *uplo, int &n, double *a, int &lda, double *w, double *work, int &lwork, int &info);
正确的链接器选项集再次取决于您的系统,并且可以是某些东西像这样:
-llapack -lf77blas -latlas
(这个集合适用于我的 Ubuntu,其中 LAPACK 来自atlas
包)。There are several ways of using LAPACK with c++. Here's what I'd do (assuming you are on some *nix system).
Make sure you have the right libraries and you know the right set of compiler/linker options. Since these are written in Fortran, I'd start with a Fortran code. Like this one. Make sure you can compile it using
gfortran
. Possible linker options can be (depending on your system):-llapack
,-lblas
or some combinations of these.Then move onto using C++ interface. Again, there are multiple ways of doing. I personally find it the easiest to use the clapack interface, where you are declaring the LAPACk functions like this:
extern "C" void dsyev_( char *jobz, char *uplo, int &n, double *a, int &lda, double *w, double *work, int &lwork, int &info);
The right set of linker options again depends on your system and can be something like this:
-llapack -lf77blas -latlas
(this set works on my Ubuntu where LAPACK comes from theatlas
package).