https://blog.csdn.net/zouyu1746430162/article/details/53374693
https://blog.csdn.net/mlnotes/article/details/9676269
https://blog.csdn.net/yuanxing14/article/details/41744461
https://blog.csdn.net/chishuideyu/article/details/78351063
1、安装gfortran
sudo apt-get install gfortran
2、下载LAPSCK,http://www.netlib.org/lapack/ 现在发布到3.5.0版本
3、解压
tar -xvf .taz
4、进入解压后文件夹后,复制make.inc.example为make.inc
cp make.inc.example make.inc
5、编辑Makefile 文件内容,把
lib: lapacklib tmglib
#lib: blaslib variants lapacklib tmglib
改为:
#lib: lapacklib tmglib
lib: blaslib variants lapacklib tmglib
6
然后,编译
如果这里遇到权限问题 permission denied,就在命令前面加sudo
sudo make -j7
在这里编译的时候,我遇到一个问题
NEP: Testing Nonsymmetric Eigenvalue Problem routines
./EIG/xeigtstz < nep.in > znep.out 2>&1
Makefile:463: recipe for target 'znep.out' failed make[1]: *** [znep.out] Error 139 make[1]: Leaving directory '/home/xfbupt/project/other/lapack-3.7.1/TESTING' Makefile:42: recipe for target 'lapack_testing' failed make: *** [lapack_testing] Error 2
这应该是测试错误,编译其实基本已经完成了
这时只需要执行下面的语句,修改一下栈的大小就可以编译成功了。
ulimit -s 1000007 cd lapacke # 进入lapacke 文件夹,这个文件夹包含lapack的C语言接口文件sudo make -j7 # 编译lapackecp include/*.h /usr/local/include #将lapacke的头文件复制到系统头文件目录cd .. #返回到 lapack-3.4.2 目录cp *.a /usr/local/lib # 将生成的所有库文件复制到系统库目录8 测试
#include <stdio.h>
#include <lapacke.h>
int main (int argc, const char * argv[])
{
double a[5*3] = {1,2,3,4,5,1,3,5,2,4,1,4,2,5,3};
double b[5*2] = {-10,12,14,16,18,-3,14,12,16,16};
lapack_int info,m,n,lda,ldb,nrhs;
int i,j;
m = 5;
n = 3;
nrhs = 2;
lda = 5;
ldb = 5;
info = LAPACKE_dgels(LAPACK_COL_MAJOR,'N',m,n,nrhs,a,lda,b,ldb);
for(i=0;i<n;i++)
{
for(j=0;j<nrhs;j++)
{
printf("%lf ",b[i+ldb*j]);
}
printf("\n");
}
return(info);
}
将上诉代码保存为test.c,编译时,别忘了使用gfortran,此外,还需要连接用到的库,编译上面的代码,应使用如下命令:
gfortran test.c -llapacke -llapack -lrefblas