Compiling & Installing OpenBLAS in Ubuntu 16.04

Pre-requisite:

  • $ sudo apt-get install gfortran

Getting OpenBLAS Source:

Building Source:

  • cd OpenBLAS
  • make FC=gfortran
make[1]: Leaving directory ‘/mnt/avkash/OpenBLAS/exports’
OpenBLAS build complete. (BLAS CBLAS LAPACK LAPACKE)
OS … Linux
Architecture … x86_64
BINARY … 64bit
C compiler … GCC (command line : gcc)
Fortran compiler … GFORTRAN (command line : gfortran)
Library Name … libopenblas_sandybridgep-r0.2.20.dev.a (Multi threaded; Max num-threads is 8)
To install the library, you can run “make PREFIX=/path/to/your/installation install”.

Installation:

  • $ sudo make PREFIX=/usr/local install
make -j 8 -f Makefile.install install
make[1]: Entering directory ‘/mnt/avkash/OpenBLAS’
Generating openblas_config.h in /usr/local/include
Generating f77blas.h in /usr/local/include
Generating cblas.h in /usr/local/include
Copying LAPACKE header files to /usr/local/include
Copying the static library to /usr/local/lib
Copying the shared library to /usr/local/lib
Generating OpenBLASConfig.cmake in /usr/local/lib/cmake/openblas
Generating OpenBLASConfigVersion.cmake in /usr/local/lib/cmake/openblas
Install OK!
make[1]: Leaving directory ‘/mnt/avkash/OpenBLAS’
Error:  If you hit the following error:  /usr/bin/ld: cannot find -lgfortran

gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\”_\” -DCHAR_CNAME=\”\” -DNO_AFFINITY -I.. -shared -o ../libopenblas_sandybridgep-r0.2.20.dev.so \
-Wl,–whole-archive ../libopenblas_sandybridgep-r0.2.20.dev.a -Wl,–no-whole-archive \
-Wl,-soname,libopenblas.so.0 -lm -lpthread -lgfortran -lm -lpthread -lgfortran
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
Makefile:133: recipe for target ‘../libopenblas_sandybridgep-r0.2.20.dev.so’ failed
make[1]: *** [../libopenblas_sandybridgep-r0.2.20.dev.so] Error 1
make[1]: Leaving directory ‘/home/ubuntu/toolkit/OpenBLAS/exports’
Makefile:85: recipe for target ‘shared’ failed
make: *** [shared] Error 2
Solution: You just need to use NO_LAPACK=1 parameter along with make.

$ make FC=gfortran NO_LAPACK=1

Thats it!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s