title: How to force armadillo library to link to local OpenBLAS during compilation
body: <p>I need to have armadillo (current version is 5.100.1) available as a local library within $HOME (cluster application, and can't install on every compute node, but $HOME is shared folder). I'm using cmake to manage the application, and have been able to get cmake to link to local libraries in $HOME (e.g., boost) rather than elsewhere just fine. Armadillo needs BLAS and LAPACK, although it can use (and in fact advises as such) OpenBLAS for both. However, I don't understand how to force armadillo to use OpenBLAS even when its own cmake .configure confirms that it has found OpenBLAS. Here is the output from running ./configure on a pristine armadillo folder:</p>
  
  <pre><code>$ ./configure
  -- Configuring Armadillo 5.100.1
  -- CMAKE_SYSTEM_NAME          = Linux
  -- CMAKE_CXX_COMPILER_ID      = GNU
  -- CMAKE_CXX_COMPILER_VERSION = 4.9.1
  -- CMAKE_COMPILER_IS_GNUCXX   = 1
  -- Found MKL libraries: /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_rt.so
  -- Found OpenBLAS: /home/rolf/lib/libopenblas.so
  -- Found BLAS: /usr/lib64/libblas.so
  -- Found LAPACK: /usr/lib64/liblapack.so
  --      MKL_FOUND = YES
  --   ACMLMP_FOUND = NO
  --     ACML_FOUND = NO
  -- OpenBLAS_FOUND = YES
  --    ATLAS_FOUND = NO
  --     BLAS_FOUND = YES
  --   LAPACK_FOUND = YES
  -- 
  -- *** If the MKL or ACML libraries are installed in non-standard locations such as
  -- *** /opt/intel/mkl, /opt/intel/composerxe/, /usr/local/intel/mkl
  -- *** make sure the run-time linker can find them.
  -- *** On Linux systems this can be done by editing /etc/ld.so.conf
  -- *** or modifying the LD_LIBRARY_PATH environment variable.
  -- 
  -- *** On systems with SELinux enabled (eg. Fedora, RHEL),
  -- *** you may need to change the SELinux type of all MKL/ACML libraries
  -- *** to fix permission problems that may occur during run-time.
  -- *** See README.txt for more information
  -- 
  -- Found ARPACK: /usr/lib64/libarpack.so
  -- ARPACK_FOUND = YES
  -- Could not find SuperLU
  -- SuperLU_FOUND = NO
  -- 
  -- *** Armadillo wrapper library will use the following libraries:
  -- *** ARMA_LIBS = /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_rt.so;/usr/lib64/libarpack.so
  -- 
  -- Detected gcc 4.8.3 or later. Added '-std=c++11' to compiler flags
  -- Copying /home/rolf/work/pdefect/armadillo/include/ to /home/rolf/work/pdefect/armadillo/tmp/include/
  -- Generating /home/rolf/work/pdefect/armadillo/tmp/include/config.hpp
  -- Generating /home/rolf/work/pdefect/armadillo/examples/Makefile
  -- CMAKE_CXX_FLAGS           =  -std=c++11 -O2
  -- CMAKE_SHARED_LINKER_FLAGS =  -Wl,--no-as-needed
  -- CMAKE_REQUIRED_INCLUDES   = 
  -- *** CMAKE_INSTALL_PREFIX was initalised by cmake to the default value of /usr/local
  -- *** CMAKE_INSTALL_PREFIX changed to /usr
  -- *** Detected 64 bit system
  -- *** /usr/lib64/ exists, so destination directory for the run-time library changed to /usr/lib64/
  -- *** Your system and/or compiler must search /usr/lib64/ during linking
  -- CMAKE_INSTALL_PREFIX = /usr
  -- INSTALL_LIB_DIR      = /usr/lib64
  -- INSTALL_INCLUDE_DIR  = /usr/include
  -- INSTALL_DATA_DIR     = /usr/share
  -- INSTALL_BIN_DIR      = /usr/bin
  -- Generating '/home/rolf/work/pdefect/armadillo/ArmadilloConfig.cmake'
  -- Generating '/home/rolf/work/pdefect/armadillo/ArmadilloConfigVersion.cmake'
  -- Generating '/home/rolf/work/pdefect/armadillo/InstallFiles/ArmadilloConfig.cmake'
  -- Generating '/home/rolf/work/pdefect/armadillo/InstallFiles/ArmadilloConfigVersion.cmake'
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/rolf/work/pdefect/armadillo
  </code></pre>
  
  <p>So it succeeds in finding it in $HOME, but if I query the library's links to shared libraries after</p>
  
  <pre><code>$ cmake .
  $ make
  </code></pre>
  
  <p>I see that it has linked to the login node's standard copies of BLAS and LAPACK, but made no use of OpenBLAS:</p>
  
  <pre><code>$ ldd libarmadillo.so.5.100.1
          linux-vdso.so.1 =&gt;  (0x00007fff05b9b000)
          libmkl_rt.so =&gt; /opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64/libmkl_rt.so (0x00007f14d2558000)
          libarpack.so.2 =&gt; /home/rolf/lib/libarpack.so.2 (0x00007f14d230a000)
          libstdc++.so.6 =&gt; /usr/lib64/libstdc++.so.6 (0x00007f14d1fe9000)
          libm.so.6 =&gt; /lib64/libm.so.6 (0x00007f14d1d64000)
          libgcc_s.so.1 =&gt; /lib64/libgcc_s.so.1 (0x00007f14d1b4e000)
          libc.so.6 =&gt; /lib64/libc.so.6 (0x00007f14d17ba000)
          /lib64/ld-linux-x86-64.so.2 (0x0000003d83400000)
          libdl.so.2 =&gt; /lib64/libdl.so.2 (0x00007f14d15b5000)
          libblas.so.3 =&gt; /usr/lib64/libblas.so.3 (0x00007f14d135e000)
          liblapack.so.3 =&gt; /usr/lib64/atlas/liblapack.so.3 (0x00007f14d0b3d000)
          libgfortran.so.3 =&gt; /usr/lib64/libgfortran.so.3 (0x00007f14d084a000)
          libf77blas.so.3 =&gt; /usr/lib64/atlas/libf77blas.so.3 (0x00007f14d062d000)
          libcblas.so.3 =&gt; /usr/lib64/atlas/libcblas.so.3 (0x00007f14d040c000)
          libatlas.so.3 =&gt; /usr/lib64/atlas/libatlas.so.3 (0x00007f14cfcfe000)
          libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x00007f14cfae1000)
  </code></pre>
  
  <p>Unfortunately, libblas.so.3 and liblapack.so.3 are not available on the nodes:</p>
  
  <pre><code>$ ssh node01 'ldd  /home/rolf/work/pdefect/armadillo/libarmadillo.so.5.100.1 | grep "not found" '
      libblas.so.3 =&gt; not found
      liblapack.so.3 =&gt; not found
  </code></pre>
  
  <p>How do I force armadillo to compile and link to my local copy of OpenBLAS, and not the standard copies of BLAS and LAPACK in /usr/lib64. There is a note in the <a href="http://arma.sourceforge.net/faq.html#blas_lapack_replacements" rel="noreferrer">faq</a> that states that</p>
  
  <pre><code>*  For Linux-based systems the automatic installer can figure out that
  OpenBLAS, MKL, ACML or ATLAS are installed, and will use them instead of
  the standard LAPACK and BLAS libraries. See README.txt within the Armadillo
  archive for more information. 
  </code></pre>
  
  <p>but from the above results, this does not seem to be the case. Can anyone point me to what I'm doing wrong here?</p>