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
- 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
- Install Armadillo using
sudo apt-get install libarmadillo-dev
- You're done installing Armadillo!
Installation on Abel
- Download Armadillo from http://arma.sourceforge.net/download.html
- Extract the downloaded files into some subdirectory of your home directory.
- 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
- You need to change the Armadillo compile script by opening the following file:
nano build_aux/cmake/Modules/ARMA_FindMKL.cmake
- Change line 21 (or the one which contains paths where CMake searches) and add the output of the above echo $MKLPATH command.
- 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
- Download Armadillo from http://arma.sourceforge.net/download.html
- Extract the downloaded files into some directory.
- If not present already, install LAPACK and BLAS with
sudo apt-get install liblapack-dev sudo apt-get install libblas-dev
- Open a terminal and change into the directory that was created by unpacking the Armadillo archive.
- 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.) - 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
- Compiling example:
g++ example.cpp -o example -O2 -L/PATH_TO_ARMADILLO_LIBRARY/include/armadillo -llapack -lblas
Automatic installation based on Cmake
- If CMake is not already present on your system, download it from http://www.cmake.org
In Ubuntu:sudo apt-get install cmake
- Download Armadillo from http://arma.sourceforge.net/download.html
- Extract the downloaded files into some directory.
- If not present already, install LAPACK and BLAS with
sudo apt-get install liblapack-dev sudo apt-get install libblas-dev
- Open a terminal and change into the directory that was created by unpacking the Armadillo archive.
-
Type
cmake . make
(CMake detects automatically which other libraries are currently installed and modifies Armadillo's configuration appropriately.) - 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.) - Make sure your C++ compiler (e.g. g++) is configured to use the sub-directories present within "myDir".