Installing BETL

Now, let's come to the compilation of BETL itself. While the library's core functionality is provided as a header-only library there are, nevertheless, a few sources which are organised in form of static libraries. This is what the current section is all about. We will explain the building process of the library as well as its installation process.

The BETL library as well as the tutorials are meant to be out-of-source projects. This means that the all the sources are separated from the build files. The advantage of this strategy is the fact that it is easily possible to have a bunch of build directories. For instance, you might want to have different build directories for debug- or release-builds. Moreover, you might want to have different locations for g++- or icc-compilations. With build folders being well-separated from the sources all that can be done in clean and simple way.

Let's assume that your copy of the BETL is located at BETL_SOURCE_PATH. Moreover, we will assume that you have created a build directory outside of the BETL's sources. For instance, a typical location for BETL's sources may be BETL_SOURCE_PATH=~/source/betl. In addition, you may want to build a release version of the BETL libraries at BETL_BUILD_PATH=~/build/betl/lib/release.

There are two more variables needed for making the compile and installation process work. First, if the Boost libraries are not located at a default path like, e.g., /usr/include/boost, /usr/local/include/boost, or /opt/local/include/boost we need to define the BOOST_ROOT variable. For instance, if you have have a local Boost installation at ~/usr/local/include/boost

export BOOST_ROOT=~/usr/local

is a valid declaration within a bash terminal. The second mandatory variable is BETL_ROOT. Equivalent to the former BOOST_ROOT variable, this variable determines the target of the BETL installation. Again, we assume that we want to install BETL at a local installation directory. Then, a possible declaration of BETL_ROOT is given below.

export BETL_ROOT=~/usr/local

With the definitions of BOOST_ROOT and BETL_ROOT the setup for the BETL installation is complete. It remains to instantiate the build system via an appropriate cmake call.

cmake $BETL_SOURCE_PATH/Library/cmk

If everything works as expected the outcome of the former call should be something like this:

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- OS settings from 'CMakeLists.unix'
-- Boost version: 1.46.0
-- Installation target: $HOME/usr/local
-- Configuring done
-- Generating done
-- Build files have been written to: $HOME/build/betl/lib/release


CMake sets the compiler configuration automatically. Unfortunately, it may happen that the system's compiler is not well-suited for compiling BETL. In this case either the environment variable CXX should be set to a valid compiler or CMake should be called with the option -DCMAKE_CXX_COMPILER=name_of_your_compiler in order to prescribe a supported compiler. For more information follow this link.

If you are working with a POSIX operating system the CMake call above creates the typical Makefiles from which the library can be build. Alternatively, you may prefer some integrated development environment (IDE) like, e.g., Eclipse, Visual Studio, or XCode. CMake can do this for you via its generator flag. Contact the CMake documentation for more details on that. Here, we will continue with building the library by using Makefiles. This is fairly simple and can be done just by typing:

make install

Note that the latter command possibly demands super user privileges which is typically the case when you have decided to install the library in some system path. Now, when everything has worked without any error messages there will be two betl folders in $BETL_ROOT/include and $BETL_ROOT/lib. While the first path consists of all necessary header files the library path should at least contain the following libraries:

ls $BETL_ROOT/lib/betl
libbetlcore.a  libformat_string.a  libresult.a
libclp.a       libgmsh_input.a     libsmpl_input.a

If you can detect those libraries in your library path everything went fine and the BETL installation is complete. Congratulations!

Concerning the instantiation of the build system one final remark should be given. If you dislike the definition of some environment variables before calling cmake, it is also possible to declare the BOOST_ROOT and BETL_ROOT variables directly within the cmake command.

cmake -D BOOST_ROOT=~/usr/local -D BETL_ROOT=~/usr/local $BETL_SOURCE_PATH/Library/cmk

Note, that as a consequence of this approach you need to define those variables every time you are generating a build system. In other words, the variables are no longer system-wide environment variables but internal cmake variables which must be specified when you are generating the Makefiles either for the library, for the tutorials, or for some self-written applications (if they rely on cmake).