How to install Lapack & Blas on linux?
Goal
LAPack and BLAS are powerfull linear algebra libraries written in fortran. Here I go over installing and using them in linux. First we need to install BLAS, and then we can install LAPack.
How to do it?
- Download the latest version of BLAS
- Open a terminal and go to the directory where you have saved it.
- $ tar -xvf blas-3.6.0.tgz # create BLAS subdirectory
- $ cd BLAS-3.6.0
- $ gfortran -O3 -c *.f # compiling
- $ ar cr libblas.a *.o # creates libblas.a
- $ sudo cp ./libblas.a /usr/local/lib/
- So far we have installed BLAS. Now download the latest version of LAPack.
- Open a terminal and go to the directory where you have saved it.
- $ tar -xvf ./lapack-3.6.0.tgz # create LAPack subdirectory
- $ cd lapack-3.6.0
- Now you need to change the directory of BLAS in the file "make.inc.example". Open this file and find the line that reads
- BLASLIB = ../../librefblas.a
- and change it to :
- BLASLIB = /usr/local/libblas.a
- Save this file as "make.inc" and then run make:
- $ make
- $ sudo cp ./liblapack.a /usr/local/lib/
- compile your code using "-lblas -llapack" flags.
- Voila!! -------------------------------------------
- If you get the error "recipe for target 'znep.out' failed" during installation of LAPack, run the command "$ ulimit -s unlimited". See this for more information. Thanks to Prof. Becker for bringing this up to my attention.