Compiling Feel++ from sources

Difficulty: difficulty advanced advanced!
For beginners, you can skip this section and go directly to containers section.

Before starting compiling Feel++, you need first to

1. For the impatient

To follow these steps, make sure that you first follow programming environment prerequisites steps.

First retrieve the source

$ git clone https://github.com/feelpp/feelpp.git

Feel++ does not allow in-source cmake, the build must be done in separate directory.

Create a build directory
$ mkdir build
$ cd build
Configure Feel++
$ CXX=clang++ ../feelpp/configure -r
Compile the Feel++ library, its tools and a few examples
$ make  (1)
$ make install (2)
1 compile Feel++: library, tools and quickstart examples
2 install Feel++
you can speed up the make process by passing the option -j<N> where N is the number of concurrent make sub-processes. It compiles N files at a time and respect dependencies. For example -j4 compiles 4 C++ files at a time.
Be aware that Feel++ consumes memory. The Feel++ library compile with 2Go of RAM. But to be more comfortable, 4Go or more would be best.
Execute your first Feel++ application in sequential
$ ./feelpp_qs_laplacian_2d --case laplacian/feelpp2d
Execute your first Feel++ application using 4 mpi processes
$ cd feelpp/quickstart
$ mpirun -np 4 feelpp_qs_laplacian_2d --case laplacian/feelpp2d

2. Downloading sources

2.1. Using Tarballs

Feel++ is distributed as tarballs following each major release. The tarballs are available on the Feel++ Releases web page.

Download the latest tarball, then uncompress it with:

$ tar -xzf feelpp-X.YY.0.tar.gz
$ cd feelpp-X.YY.0

You can now move to the section Using cmake.

2.2. Using Git

Alternatively, you can download the sources of Feel++ directly from the Git repository.

$ git clone  https://github.com/feelpp/feelpp.git

You should read something like

Cloning into 'feelpp'...
remote: Counting objects: 129304, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 129304 (delta 6), reused 0 (delta 0), pack-reused 129283
Receiving objects: 100% (129304/129304), 150.52 MiB | 1.69 MiB/s, done.
Resolving deltas: 100% (94184/94184), done.
Checking out files: 100% (7237/7237), done.
$ cd feelpp

The first level directory tree is as follows

$ tree -L 1 -d
.
├── benchmarks
├── cmake
├── data
├── databases
├── doc
├── feelpp
├── mor
├── ports
├── research
├── testsuite
└── toolboxes

3. Configuring Feel++

For now on, we assume that clang++ has been installed in /usr/bin. Yor mileage may vary depending on your installation of course.

It is not allowed to build the library in the top source directory.

It is recommended to have a directory (e.g. FEEL) in which you have both the sources and build directories, as follows

$ ls FEEL
feelpp/ # Sources
feel.opt/ # Build directory

feelpp is the top directory where the source have been downloaded, using git or tarballs.

the components Feel++ toolboxes and mor are not configured and compiled by default, you have to enable them either using cmake or convenience script configure

3.1. Using cmake

The configuration step with cmake is as follows

$ cd FEEL/feel.opt
$ cmake ../feelpp (1)
1 Run cmake with default configuration flags from toplevel Feel++ source directory in ../feelpp
Use ccmake to configure Feel++ using a graphical or text interface.
$ cd FEEL/feel.opt
$ cmake ../feelpp
 -DCMAKE_CXX_COMPILER=/usr/bin/clang++  (1)
 -DCMAKE_C_COMPILER=/usr/bin/clang  (2)
 -DCMAKE_BUILD_TYPE=RelWithDebInfo (3)
1 set the C++ compiler to /usr/bin/clang++
2 set the C compiler to /usr/bin/clang
3 set the cmake build type to RelWithDebInfo

Feel++ supports different cmake build types that you can set with -DCMAKE_BUILD_TYPE (case insensitive) :

CMAKE_BUILD_TYPE

CMAKE_CXX_FLAGS_<BUILDTYPE>

Comment

None

Debug

-g -O1

Debug mode with slight optimization to ensure some performance but some objects may be optimized away while debugging

DebugFull

-g -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls

Debug without any optimization to avoid objects to be optimized away at the cost of performance

Release

-O3 -DNDEBUG

Optimize the code aggressively

RelWithDebInfo

-g -O2 -DNDEBUG

Asan

-g -O1 -fsanitize=address,leak -fno-omit-frame-pointer -fno-optimize-sibling-calls

Enable Address and Leak Sanitizers

Coverage

-g -O0 --coverage

Enable Coverage Reporting for GCC/Clang

Enable Feel++ toolboxes and mor using `cmake
cmake ../feelpp ... -DFEELPP_ENABLE_TOOLBOXES=ON -DFEELPP_ENABLE_MOR=ON

3.2. Using configure

Alternatively you can use the configure script which calls cmake. configure --help provides the following help.

Listing Configure help
./configure [options...]
Options:
 -b, --build                         build type: Debug, Release, RelWithDebInfo
 -d, --debug                         debug mode
-rd, --relwithdebinfo                relwithdebinfo mode
 -r, --release                       release mode
     --std=c++xx                     c++ standard c++14, c++1z (default: c++14)
     --stdlib=libxx                  c++ standard library libstdc++, libc++ (default: libstdc++)
     --max-order=x                   maximum polynomial order to instantiate(default: 3)
     --cxxflags                      override cxxflags
     --cmakeflags                    add extra cmake flags
     --prefix=PATH                   define install path
     --root=PATH                     define root path
     --enable-pch                    enable precompiled headers (default)
     --disable-pch                   disable precompiled headers
     --enable-python                 enable python
     --enable-cling                  enable cling
     --disable-cling                 disable cling (default)
     --enable-toolboxes              enable Feel++ toolboxes and PyFeel++ toolboxes
     --disable-toolboxes             disable Feel++ toolboxes and PyFeel++ toolboxes (by default)
     --enable-mor                    enable Feel++ mor and PyFeel++ mor
     --disable-mor                   disable Feel++ mor and PyFeel++ mor (by default)
 -v, --verbose                       enable verbose output
 -h, --help                          help page
     --<package>-dir=PACKAGE_PATH    define <package> install directory
     --disable-<package>             disable <package>
     --generator=GENERATOR           cmake generator

We display below a set of possible configurations:

Compile using Release build type, default c compiler and libstdc
Listing compiling using default compilers
$ ../feelpp/configure -r
Setup and compile Feel++, the Feel++ toolboxes and Feel++ mor
Listing to compile Feel++, the Feel++ toolboxes and Feel++ mor
../feelpp/configure -r --enable-toolboxes --enable-mor
Compile using Release build type, clang compiler and libstdc
Listing compiling using clang++
$ CXX=clang++ ../feelpp/configure -r
Compile using Debug build type, clang compiler and libc
Listing compiling using clang/libc in Debug mode
CXX=clang++ ../feelpp/configure -d -stdlib=c++

4. Compiling Feel++

Once cmake or configure have done their work successfully, you are ready to compile Feel++

$ make
$ make install
Parallel compilation

You can speed up the compilation process, if you have a multicore processor by specifying the number of parallel jobs make will be allowed to spawn using the -j flag:

Listing build Feel++ library using 4 concurrent jobs
$ make -j4 feelpp
From now on, all commands should be typed in build directory (e.g feel.opt) or its subdirectories.