title: how to compile lapack so that it can be used correctly during installation of octave?
body: <p>I'm trying to install the latest octave 3.8.1 from source in a cluster running redhat+IBM LSF. I don't have write access to anywhere else except my own home dir, that's why I have to install octave from source. The blas and lapack provided by the cluster does not work so I have to build them by myself. I have now finished compiling both blas and lapack and passed the <code>./configure</code>, but when I run make, an error is reported as follows: </p>
  
  <p><img src="https://i.stack.imgur.com/M3BQw.png" alt="enter image description here"></p>
  
  <p>These are steps I used to build my own <code>BLAS</code> and <code>LAPACK</code>. The source of BLAS is in <code>~/src/BLAS</code> while the source of LAPACK is in <code>~/src/lapack-3.5.0</code> and the source of octave 3.8.1 is in <code>~/src/octave-3.8.1</code>.
  With only two module, <code>1) pcre/8.33 2) acml/5.3.1/gfortran64</code>, loaded, I compiled BLAS shared library using</p>
  
  <pre><code>gfortran -shared -O2 *.f -o libblas.so -fPIC
  </code></pre>
  
  <p>and static library using</p>
  
  <pre><code>gfortran -O2 -c *.f -fPIC
  ar cr libblas.a *.o
  </code></pre>
  
  <p>Then I copy the shared library <code>libblas.so</code> to ~/src/octave-3.8.1. The contents of <code>make.inc</code> file in lapack's dir is:</p>
  
  <pre><code>####################################################################
  #  LAPACK make include file.                                       #
  #  LAPACK, Version 3.5.0                                           #
  #  November 2013                                                   #
  ####################################################################
  #
  SHELL = /bin/sh
  #  
  #  Modify the FORTRAN and OPTS definitions to refer to the
  #  compiler and desired compiler options for your machine.  NOOPT
  #  refers to the compiler options desired when NO OPTIMIZATION is
  #  selected.  Define LOADER and LOADOPTS to refer to the loader and 
  #  desired load options for your machine.
  #
  FORTRAN  = gfortran 
  OPTS     = -shared -O2 -fPIC
  DRVOPTS  = $(OPTS)
  NOOPT    = -O0 -frecursive
  LOADER   = gfortran
  LOADOPTS =
  #
  # Timer for the SECOND and DSECND routines
  #
  # Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
  #TIMER    = EXT_ETIME
  # For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
  # TIMER    = EXT_ETIME_
  # For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
  TIMER    = INT_ETIME
  # If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
  # SECOND and DSECND will use a call to the INTERNAL FUNCTION CPU_TIME
  # TIMER    = INT_CPU_TIME
  # If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
  # TIMER     = NONE
  #
  #  Configuration LAPACKE: Native C interface to LAPACK
  #  To generate LAPACKE library: type 'make lapackelib'
  #  Configuration file: turned off (default)
  #  Complex types: C99 (default)
  #  Name pattern: mixed case (default)
  #  (64-bit) Data model: LP64 (default)
  #
  # CC is the C compiler, normally invoked with options CFLAGS.
  #
  CC = gcc
  CFLAGS = -O3
  #
  #  The archiver and the flag(s) to use when building archive (library)
  #  If you system has no ranlib, set RANLIB = echo.
  #
  ARCH     = ar
  ARCHFLAGS= cr
  RANLIB   = ranlib
  #
  #  Location of the extended-precision BLAS (XBLAS) Fortran library
  #  used for building and testing extended-precision routines.  The
  #  relevant routines will be compiled and XBLAS will be linked only if
  #  USEXBLAS is defined.
  #
  # USEXBLAS    = Yes
  XBLASLIB     =
  # XBLASLIB    = -lxblas
  #
  #  The location of the libraries to which you will link.  (The 
  #  machine-specific, optimized BLAS library should be used whenever
  #  possible.)
  #
  #BLASLIB      = ../../librefblas.a
  BLASLIB      = ~/src/BLAS/libblas.a
  LAPACKLIB    = liblapack.a
  TMGLIB       = libtmglib.a
  LAPACKELIB   = liblapacke.a
  </code></pre>
  
  <p>Then I type make to compile LAPACK. After compilation, I copied the output <code>liblapack.a</code> to ~/src/octave-3.8.1.</p>
  
  <p>The <code>./configure</code> command line is:</p>
  
  <pre><code>./configure --prefix=$HOME/bin/octave --with-blas=./libblas.so --with-lapack=$HOME/src/octave-3.8.1/liblapack.a --disable-readline --enable-64
  </code></pre>
  
  <p>I can pass the ./configure. Then I type <code>make</code> to try to build octave 3.8.1 and I got the above error.</p>
  
  <p>From the <code>make.inc</code> file it can be seen that I have followed the suggestion of the compiler "<code>recompile with -fPIC</code>" and modified the make.inc accordingly. I also add <code>-shared</code> switch in the <code>OPTS</code> variable. In addition, I have tried using old LAPACK version but not working. I really have no idea why the error still comes out. So I wonder if you could please tell me how to compile the <code>LAPACK</code> library so that it can be correctly used during installation of octave 3.8.1. The following two points may be worth considering. (1) should I compile lapack as a static library or a shared library? (2) should <code>-fPIC</code> switch be applied to lapack compilation or octave's <code>make</code>? If the latter, how to apply -fPIC to make? You don't have to get restricted to the above two points since there may be other reasons for the error. Any advice to solve this problem is welcomed. If you need any other information please tell me. Thank you. </p>