Compiling from Source
Table of contents
Choice of Compiler
In order to compile CREST from source you will need a Fortran and C compiler. We recommend either the Intel ifort
/icx
or GNU gfortran
/gcc
compilers. Both compilers can be obtained free-of-charge, but you’ll only need one of them. A quick reference on where to obtain either one is proveded in the following.
1. GNU compilers
Installing the gfortran
and gcc
compilers on Unix systems is fairly straight-foward. The installation can be done directly via the commandline, e.g., with
sudo apt-get install gfortran
Check the installation and gfortran
version with
gfortran --version
The gcc
compiler is included in the build-essential
package and there is a good chance you have installed this on your Linux system already. If not, try installing it via
sudo apt update
sudo apt-get install build-essentials
and check the gcc
version with
gcc --version
If you decided on the GNU compilers, set them as your defaults:
export FC=gfortran CC=gcc
In case you are going for the GNU compilers, it also makes sense to install openBLAS as a linear algebra backend, for example on Ubuntu via
sudo apt-get install libopenblas-dev
2. Intel compilers via oneAPI
The ifort
and icx
compilers have become publically available only recently with the introduction of Intel’s oneAPI initiative . You will need to first install the Intel oneAPI Base Toolkit and afterwards the Intel oneAPI HPC Toolkit . Follow the instructions and check the installation via
ifort -v
If this gives you a version number, set these compilers as your defaults:
export FC=ifort CC=icx
Install via CMake
CMake is one of the most widely used multiplatform build systems. Starting with CREST 3.0, we will focus primarily on this build, although the meson build may still be used
It can be used with Ninja or the regular make
as a backend. CMake can be installed in different ways. For example from the official webiste, or via pip
pip install cmake
For the next steps you will need to have chosen a compiler (ifort
/icx
or gfortran
/gcc
) and exported the FC
and CC
variables as described above . To start building CREST, navigate to the source (a file called CMakeLists.txt
should be present here) and setup a _build
directory with
cmake -B _build
Further arguments can be added to this command if you wish to customize the build, for example for including or excluding suprojects. Information about the subprojects is given on the programs repository page .
Then build the project with
make -C _build
If you wish to use Ninja as a backend (instead of make
), add the -GNinja
option to the CMake setup command.
Starting with CREST 3.0, we introduce unit tests that can be run via the CMake build. To run these, after having build the program, use
make test -C _build
The unit tests will be expanded over time.
Install via Meson
Meson is an open source multiplatform build system. The main development project can be found on Meson’s GitHub page . Meson is used in combination with the Ninja build system (version > 1.8) as a backend. Both can be installed from the command line via pip
(Python version > 3.7).
python3 -m pip install meson ninja
OR via
sudo apt install meson ninja-build
Check their installation with
meson --version ; ninja --verison
Instructions for building CREST with Meson are read from the meson.build
file. As before, you must have exported FC
and CC
variables to set the compilers. However, momentarily the meson build defaults only work with the ifort/icx
architecture. To start building the program, navigate to the directory in which you have saved CREST and set up the build with
meson setup _build
This will prepare the directory _build
in which the program will be compiled.
-Dla_backend=<option>
keyword to the setup command. For example, add -Dla_backend=mkl
to use the shared MKL library.If the setup was successfull, initiate the build (still in the same directory) with
ninja -C _build