https://blog.csdn.net/zouyu1746430162/article/details/53374693css
https://blog.csdn.net/mlnotes/article/details/9676269bash
https://blog.csdn.net/yuanxing14/article/details/41744461ide
https://blog.csdn.net/chishuideyu/article/details/78351063測試
一、安裝gfortranui
sudo apt-get install gfortranspa
二、下載LAPSCK,http://www.netlib.org/lapack/ 如今發佈到3.5.0版本.net
三、解壓code
tar -xvf .taz blog
四、進入解壓後文件夾後,複製make.inc.example爲make.inc接口
cp make.inc.example make.inc
五、編輯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 100000
7
cd lapacke # 進入lapacke 文件夾,這個文件夾包含lapack的C語言接口文件
sudo make -j7 # 編譯lapacke
cp 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