It is the integration of several others learn from the article, but did a little modification. (Who was originally, and forget)
1. Make sure gfortran compiler installed on the machine, if not installed, you can use
sudo apt-get install gfortran
2. Download blas, cblas, lapack source code
The source code can be in http://www.netlib.org found on, download and unzip. Here when I installed the download link http://www.netlib.org/blas/blas.tgz
http://www.netlib.org/blas/blast-forum/cblas.tgz
HTTP: //www.netlib. org / lapack / lapack-3.4.2.tgz
have three folders after unpacking, BLAS, cBLAS, lapack-3.4.2
3. Here is a specific compilation step (must be in order)
tar xvf blas.tgz #解压三个文件
1) Compile blas
BLAS enter folder, execute the following few commands
gfortran -c -O3 *.f # 编译所有的 .f 文件,生成 .o文件
ar rv libblas.a *.o # 链接所有的 .o文件,生成 .a 文件
su cp libblas.a /usr/local/lib # 将库文件复制到系统库目录
##################################################################
#如果上面代码有问题,可以试试下面的编译方法
gfortran -c -O3 -fPIC *.f # 编译所有的 .f 文件,生成 .o文件 加上了-fPIC
gcc -shared *.o -fPIC -o libblas.so
cp libblas.so /usr/local/lib/
ar rv libblas.a *.o # 链接所有的 .o文件,生成 .a 文件
su cp libblas.a /usr/local/lib # 将库文件复制到系统库目录
2) Compile cblas
Enter CBLAS folder, first of all according to your own computer platform, the directory is a copy Makefile.XXX Makefile.in, XXX represents the platform of the computer, if it is Linux, then it will Makefile.LINUX copied to Makefile.in, then execute the following command
cp ../BLAS/libblas.a testing # 将上一步编译成功的 libblas.a 复制到 CBLAS目录下的testing子目录
make # 编译所有的目录
sudo cp lib/cblas_LINUX.a /usr/local/lib/libcblas.a # 将库文件复制到系统库目录下
problem:
File "./lapack_testing.py",line 17
**except getopt.error, msg:
^**
syntaxError:invalid syntax
Make:***[lapack_testing] Error 1
#注意,这里可能有`一个关于python的保存,主要原因是我们现在使用的是python3,
#但是编译使用的是python2,我们需要把这个文件第一行修改为在python2环境下执行。
#第一行最后加一个2就可以。
3) compile and lapacke lapack
This step is too much trouble, of course, is the first to enter the lapack-3.4.2 folder, and then according to the characteristics of the platform, under the corresponding INSTALL directory make.inc.XXX copy next to lapack-3.4.2 directory, and name it make .inc, I copied here is INSTALL / make.inc.gfortran, because I am here is gfortran compiler.
Modify lapack-3.4.2 / Makefile, because since lapack to blas library, you need to make the following changes
#修改~!
#lib: lapacklib tmglib
lib: blaslib variants lapacklig tmglib
Modify make.inc file
BLASLIB = /usr/local/lib/libblas.a
CBLASLIB = /usr/local/lib/libcblas.a
LAPACKLIB = liblapack.a
TMGLIB = libtmglib.a
LAPACKELIB = liblapacke.a
Mainly set up corresponding path cblas blas and link object files (in the system database directory). Then run the code:
make # 编译所有的lapack文件
cd lapacke # 进入lapacke 文件夹,这个文件夹包含lapack的C语言接口文件
make # 编译lapacke
cp include/*.h /usr/local/include #将lapacke的头文件复制到系统头文件目录
cd .. #返回到 lapack-3.4.2 目录
cp *.a /usr/local/lib # 将生成的所有库文件复制到系统库目录
Here's the header file include: lapacke.h, lapacke_config.h, lapacke_mangling.h, lapacke_mangling_with_flags.h lapacke_utils.h
Generate libraries include: liblapack.a, liblapacke.a, librefblas.a, libtmglib.a
So far cblas and lapack successfully installed on your computer.
Reproduced in: https: //www.jianshu.com/p/33c4aea6117b