Installing Armadillo

This guide will show you step-by-step how to install Armadillo, the C++ linear algebra library, in your home directory.

Installation at the datalab

Armadillo, LAPACK and BLAS is already installed. Just remember to link to these. In Qt Creator, just add the following line to your .pro file:

LIBS += -llapack -lblas -larmadillo

Easiest version for Ubuntu users

  1.  If not present already, install LAPACK, Boost and BLAS  with 
    sudo apt-get install liblapack-dev
    sudo apt-get install libblas-dev
    sudo apt-get install libboost-dev
  2. Install Armadillo using 
    sudo apt-get install libarmadillo-dev
  3. You're done installing Armadillo!

Installation on Abel

  1. Download Armadillo from http://arma.sourceforge.net/download.html
  2. Extract the downloaded files into some subdirectory of your home directory.
  3. You need to change the Armadillo compile script and add a path for CMake to search in. This path is found by running
    module load intel
    echo $MKLPATH
  4. You need to change the Armadillo compile script by opening the following file:
    nano build_aux/cmake/Modules/ARMA_FindMKL.cmake
  5. Change line 21 (or the one which contains paths where CMake searches) and add the output of the above echo $MKLPATH command.
  6. Run the following to compile and install armadillo. It will be installed into '~/usr':
    module load cmake
    cmake .
    make install DESTDIR=~

Manual Installation on your computer

  1. Download Armadillo from http://arma.sourceforge.net/download.html
  2. Extract the downloaded files into some directory.
  3.  If not present already, install LAPACK and BLAS  with 
    sudo apt-get install liblapack-dev
    sudo apt-get install libblas-dev
  4. Open a terminal and  change into the directory that was created by unpacking the Armadillo archive.
  5. Copy the entire "include" folder to a convenient location and tell your compiler to use that location for header files (in addition to the locations it uses already). 
    Alternatively
    Use the "include" folder directly, i.e. when you link your program later on, link with : 
    -L/PATH_TO_ARMADILLOLIBRARY/include/armadillo,  (see example in point (7.))
    (With this version you are absolutely safe when using different machines and operating systems.
    )
  6. Modify "include/armadillo_bits/config.hpp" to indicate that LAPACK and BLAS are present. This means that you have to uncomment the following lines:
    #define ARMA_USE_LAPACK
    #define ARMA_USE_BLAS
  7.  Compiling example: 
    g++ example.cpp -o example -O2  -L/PATH_TO_ARMADILLO_LIBRARY/include/armadillo -llapack -lblas

 

Automatic installation based on Cmake

  1.  If CMake is not already present on your system, download it from http://www.cmake.org
    In Ubuntu: 
    sudo apt-get install cmake
  2. Download Armadillo from http://arma.sourceforge.net/download.html
  3. Extract the downloaded files into some directory.
  4.  If not present already, install LAPACK and BLAS  with 
    
    sudo apt-get install liblapack-dev
    sudo apt-get install libblas-dev
  5. Open a terminal and  change into the directory that was created by unpacking the Armadillo archive.
  6. Type

    
    cmake .
    make 
    (CMake detects automatically which other libraries are currently installed and  modifies Armadillo's configuration appropriately.)
  7.  If you have access to root/administrator privileges, type the following command:
    'sudo make install'  
    
    (If you do not have root/administrator privileges (e.g. on UiO machines), use: make install DESTDIR=myDir, where you use the directory "myDir" (somewhere in your home directory ) to store C++ headers and library files.)
  8. Make sure your C++ compiler (e.g. g++) is configured to use the sub-directories present within "myDir".
By Sarah Reimann
Published Jan. 15, 2013 4:44 PM - Last modified Jan. 15, 2014 1:47 PM