Skip to content

Instantly share code, notes, and snippets.

@kparrish
Last active August 25, 2017 11:40
Show Gist options
  • Save kparrish/6466639 to your computer and use it in GitHub Desktop.
Save kparrish/6466639 to your computer and use it in GitHub Desktop.
A bash script to install lapack and lapacke on a Debian (Ubuntu) machine. To install run the script: sudo bash lapack_install.sh
#!/bin/bash
### LAPACK Ubuntu install
# Assign user name
read -p "Enter your user name: " UserName
### MAIN ###
# Install required packages
apt-get update
apt-get -y upgrade
apt-get -y install gfortran
cd ~/Downloads
# Check/remove lapack-3.4.2.tgz
if [ -f ~/Downloads/lapack-3.4.2.tgz ]
then
rm ~/Downloads/lapack-3.4.2.tgz
fi
# Download lapack-3.4.2.tgz
sudo -u $UserName wget http://www.netlib.org/lapack/lapack-3.4.2.tgz
# Extract lapack-3.4.2.tgz
sudo -u $UserName tar xzf ~/Downloads/lapack-3.4.2.tgz
# Compile and Install
cd ~/Downloads/lapack-3.4.2
sudo -u $UserName cp make.inc.example make.inc
sudo -u $UserName sed -i -e 's/..\/..\/librefblas.a/-lf77blas -lcblas -latlas -lgfortran/g' make.inc
sudo -u $UserName make
cd lapacke
sudo -u $UserName make
cd ~
# Change Change lapacke.h file
sudo -u $UserName sed -i -e 's/\/* Complex types are structures equivalent to the/*\/\n\n#define lapack_complex_float std::complex<float>\n#define lapack_complex_double std::complex<double>\n\n\/* Complex types are structures equivalent to the/g' ~/Downloads/lapack-3.4.2/lapacke/include/lapacke.h
# Move files
mkdir /usr/local/include/lapack/
cp ~/Downloads/lapack-3.4.2/lapacke/include/* /usr/local/include/lapack/
cp ~/Downloads/lapack-3.4.2/liblapack.a ~/Downloads/lapack-3.4.2/liblapacke.a ~/Downloads/lapack-3.4.2/libtmglib.a /usr/local/lib/
# Cleanup
rm ~/Downloads/lapack-3.4.2.tgz
rm -r ~/Downloads/lapack-3.4.2
echo "LAPACK Install Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment