-
-
Notifications
You must be signed in to change notification settings - Fork 178
Dependencies
This page describes the dependencies used by preCICE and how to build them. After you install them, you may proceed with building preCICE.
Note: Some of these instructions were written for building preCICE with SCons and not all the steps may be necessary when building with CMake.
- The easy way
- C++ compiler (with support for C++11, e.g. GCC version >= 5)
- CMake (version high enough to support your boost version)
- Eigen
- Boost (version >= 1.65.1)
- libxml2
- PETSc (optional) (version >= 3.6)
- Python (optional) (with NumPy)
- MPI (optional) (warning: problems with MPI_Ports using OpenMPI >= 2)
- SCons (deprecated)
If you want build preCICE on your own computer and you are using one of the following Linux distributions, we provide a summary here to quickly install everything you need. If everything works, you may ignore the rest of this page.
Other modern versions of popular Linux distributions are also perfectly compatible. Since our users have tried preCICE on various distributions, you may as well ask on our mailling list for any questions.
In Ubuntu 18.04 or newer, everything is available through the distribution's repositories:
sudo apt update && \
sudo apt install build-essential cmake libeigen3-dev libxml2-dev petsc-dev libboost-all-dev python-dev python-numpy
Please consider building with CMake, or click here to see more details for SCons (...)
If you are building with SCons, you also need to install scons
and to add the following in your ~/.bashrc
file (modify the paths, if needed):
# Eigen
export CPLUS_INCLUDE_PATH="/usr/include/eigen3:$CPLUS_INCLUDE_PATH"
# PETSc
export PETSC_DIR=/usr/lib/petscdir/3.7/
export LD_LIBRARY_PATH=$PETSC_DIR/lib:$LD_LIBRARY_PATH
export CPATH=$PETSC_DIR/include:$CPATH
export LIBRARY_PATH=$PETSC_DIR/lib:$LIBARY_PATH
export PYTHONPATH=$PETSC_DIR/lib:$PYTHONPATH
In Ubuntu 16.04, almost everything is available through the distribution's repositories. You only have to install Boost in another way, since only an older, incompatible version is available.
-
Install all the available dependencies through APT:
sudo apt update && \ sudo apt install build-essential cmake libeigen3-dev libxml2-dev petsc-dev python-dev python-numpy
-
Install Boost. In the Ubuntu 16.04 repositories, only Boost 1.58 is avaiable, so you need to build an appropriate Boost version from source (see option 2). Also, you need to build petsc from the source if you are to use OpenFOAM adapter (see below how to install it from the source).
-
Get a recent version of CMake.
Please consider building with CMake, or click here to see more details for SCons (...)
If you want to build preCICE with SCons, you need to install scons
and also:
- Add the following in your
~/.bashrc
(e.g. withgedit ~/.bashrc
):# Eigen export CPLUS_INCLUDE_PATH="/usr/include/eigen3:$CPLUS_INCLUDE_PATH" # PETSc export PETSC_DIR=/usr/lib/petscdir/3.6.2/. # if you are using OpenFOAM adater, edit this line for yousrself export PETSC_ARCH=x86_64-linux-gnu-real export LD_LIBRARY_PATH=$PETSC_DIR/$PETSC_ARCH/lib:$LD_LIBRARY_PATH export CPATH=$PETSC_DIR/include:$PETSC_DIR/$PETSC_ARCH/include:$CPATH export LIBRARY_PATH=$PETSC_DIR/$PETSC_ARCH/lib:$LIBARY_PATH export PYTHONPATH=$PETSC_DIR/$PETSC_ARCH/lib:$PYTHONPATH
- When running SCons to build preCICE, don't build the
tests
target. For example, run it like this (specified targets, but onlysolib
andsymlink
):scons petsc=yes python=no -j 4 solib symlink
- Packages are installed as follows:
sudo yum groupinstall 'Development Tools'
sudo yum update
sudo yum install cmake3 libxml2-devel eigen3 openmpi-devel python-devel
export PATH=/usr/lib64/openmpi/bin:$PATH
export CC=/opt/rh/devtoolset-7/root/usr/bin/gcc
- Boost library installation is done as follows:
sudo yum install boost169-devel
export BOOST_LIBRARYDIR=/usr/lib64/boost169/
export BOOST_INCLUDEDIR=/usr/include/boost169/
- The pre-installed gcc compiler is an older version which leads to the following known error. Multiple versions of gcc can be installed:
- Installing a newer version of gcc via a software development package:
sudo yum install centos-release-scl
sudo yum install devtoolset-7
- To enable the new gcc compiler in a terminal:
scl enable devtoolset-7 bash
- Use
cmake3
instead ofcmake
for the configuration of preCICE.
A C++ compiler with full support for C++11 is needed to build preCICE. We plan to increase this requirement to C++14 soon.
If you are using the GNU Compiler Collection, at least version 5 is required.
If you are using Debian/Ubuntu, the build-essential
package will install everything needed.
When compiling with MPI=on
, you need to use a compatible MPI compiler/wrapper. For example, check if the mpicxx --version
reports a compatible GCC version.
preCICE uses Eigen for linear algebra computations and the latest version should work.
You may as well install Eigen through your package manager (e.g. package libeigen3-dev
).
Please consider building with CMake, or click here to see more details for SCons (...)
If Eigen is installed but SCons cannot find it, you may need to set the CPLUS_INCLUDE_PATH
environment variable for compilation, like this:
CPLUS_INCLUDE_PATH="/usr/include/eigen3" scons [...]
Eigen is a header-only library, i.e. it's being compiled into preCICE.
Download the source from their website and extract it to some folder.
Set the environment variable Eigen3_ROOT
to the extracted folder.
Please consider building with CMake, or click here to see more details for SCons (...)
For building with SCons, please add the above folder to the include path.
export CPLUS_INCLUDE_PATH=/path/to/eigen:$CPLUS_INCLUDE_PATH
We recommend that you build preCICE using CMake. However, your CMake version might be too old for your Boost version. You can check your CMake version using cmake --version
If you use Ubuntu, you get cmake through your distribution:
sudo apt update && \
sudo apt install cmake
Warning: the CMake version provided by your package manager might be too old (see above). Then you have to continue with option 2.
See this page for instructions.
preCICE uses Boost for several features and at least version 1.65.1 or higher is required. While Boost 1.67 or newer also works with preCICE, it may complicate how you install adapters that use yaml-cpp. Note that users have experienced problems building Boost 1.69 with some compilers.
You might save some time and space by installing only the necessary libraries:
boost_log
boost_log_setup
boost_thread
boost_system
boost_filesystem
boost_program_options
boost_unit_test_framework
These libraries may also depend on other Boost libraries. Make sure that these get installed, too.
The following header-only Boost libraries are also needed: vmd
, geometry
, signals2
, container
, ranges
.
If you use Ubuntu, at least version 18.04, you get a suitable version through your distribution:
sudo apt update && \
sudo apt install libboost-dev libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev
If, for any reason, the dependencies of Boost on itself are not resolved correctly, try installing the complete colection: libboost-all-dev
.
If your distribution provides an older version of Boost, you need to build it from source. Here is an example for Ubuntu 16.04 and Boost 1.66:
- Download and extract Boost into any directory. Switch to that directory.
- Prepare the installation, selecting only the libraries that need to be built (this does not affect the header-only libraries). We will later move these files to the system directory
/usr/local
. Execute:./bootstrap.sh --with-libraries=log,thread,system,filesystem,program_options,test --prefix=/usr/local
- Install the libraries. Since
/usr/local
is a system directory, we need root access:This will copy the libraries tosudo ./b2 install
/usr/local/lib
and the all the Boost headers to/usr/local/include
. You may then remove the Boost directory. - Update the dynamic linker's run-time bindings:
sudo ldconfig
For more information, please refer to the "Getting Started" instructions of Boost.
If you do not have root access, choose another prefix and set the appropriate environment variables:
# ==== boost ====
BOOST_ROOT=$HOME/software/boost # replace with the actual path
export LIBRARY_PATH=$BOOST_ROOT/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=$BOOST_ROOT/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=$BOOST_ROOT/include:$CPLUS_INCLUDE_PATH
Note: You may already have an older version, e.g. as part of a solver installation (e.g. OpenFOAM). Be cautious, as auto-removing the old version may uninstall your solver.
preCICE uses libxml2 for parsing the configuration file and the latest version should work.
Most likely, the library is already installed. In order to compile preCICE, you also need the development package (libxml2-dev
on Debian/Ubuntu).
You need PETSc if you want to use parallel RBF mappings. If you don't need this feature, you may specify petsc=off
when using SCons.
We require at least version 3.6.
In Debian/Ubuntu, install the packages libpetsc3.6
and petsc-dev
.
Then set the environment variables PETSC_DIR
and PETSC_ARCH
in your ~/.bashrc
. For example:
export PETSC_DIR=/usr/lib/petscdir/3.6.2/
export PETSC_ARCH=x86_64-linux-gnu-real
If you prefer to install the most recent version from source, do the following:
- Get it from http://www.mcs.anl.gov/petsc/download/index.html or using
git clone -b maint https://bitbucket.org/petsc/petsc petsc
- Change into that directory and compile with or without debugging:
./configure --with-debugging=0
(disable debugging for optimal performance) - Use the make command like the configure script proposes, e.g.
make PETSC_DIR=/data2/scratch/lindner/petsc PETSC_ARCH=arch-linux2-c-opt all
Further documentation see: http://www.mcs.anl.gov/petsc/documentation/installation.html - Usage: You will need to add petsc to your dynamic linker search path (
LD_LIBRARY_PATH
on Linux orDYLD_LIBRARY_PATH
on macOS). You may also need to set the$PETSC_ARCH
.
Finally, in some cases you may need to have PETSc in your CPATH
, LIBRARY_PATH
, or PYTHONPATH
. Here is an example:
export PETSC_DIR=/path/to/petsc
export PETSC_ARCH=arch-linux2-c-debug
export LD_LIBRARY_PATH=$PETSC_DIR/$PETSC_ARCH/lib:$LD_LIBRARY_PATH
# Especially for SCons
export CPATH=$PETSC_DIR/include:$PETSC_DIR/$PETSC_ARCH/include:$CPATH
export LIBRARY_PATH=$PETSC_DIR/$PETSC_ARCH/lib:$LIBRARY_PATH
export PYTHONPATH=$PETSC_DIR/$PETSC_ARCH/lib
You only need Python if you want to use the Python action interface (only used for rare applications). If you don't need this feature, you may specify python=off
when using SCons.
In particular, you don't need to build with Python if you only want to use the Python bindings.
You probably already have Python installed. Howewer, in order to use the Python interface, you also need to install NumPy and the header files for Python and NumPy. On Debian/Ubuntu, install the packages python-numpy
and python-dev
.
Please consider building with CMake, or click here to see more details for SCons (...)
Note: you may specify custom paths for Python and NumPy, although this is normally not needed, like this:
export PRECICE_PYTHON_LIB="python2.7"
export PRECICE_PYTHON_INC_PATH="/usr/include/python2.7/"
export PRECICE_NUMPY_INC_PATH="/usr/include/python2.7/numpy/"
You can build preCICE without MPI in case of compatibility issues with a certain solver (e.g. a closed source solver with a binary-distributed MPI version, or when running on Windows). To do so, use -DMPI=OFF
when building with CMake. In such a case, you can still use TCP/IP sockets instead. This might, however, result in lower performance and is, therefore, not recommended if not necessary.
Please note that OpenMPI does not currently fully support the MPI ports functionality [citation needed]. In case you link to OpenMPI, you cannot use MPI for the m2n communication of preCICE. Additionally, the tests for MPI Ports will fail. Read more in the Tests Troubleshooting.
Keep in mind that already PETSc should have installed MPI. Make sure that PETSc, preCICE, and your solvers are all compiled with the same MPI version!
Guide to installing the Python bindings for 2.7.17 (...)
This guide provides steps to install python bindings for precice-1.6.1 for a conda environment Python 2.7.17 on the CoolMUC. Note that preCICE no longer supports Python 2 after v1.4.0. Hence, some modifications to the python setup code was necessary. Most steps are similar if not identical to the basic guide without petsc or python above. This guide assumes that the Eigen dependencies have already been installed.
Load the prerequisite libraries:
module load gcc/7
module unload mpi.intel
module load mpi.intel/2018_gcc
module load cmake/3.12.1
At the time of this writing module load boost/1.68.0
is no longer available. Instead
boost 1.65.1 was installed per the boost and yaml-cpp
guide above.
In order to have the right python dependencies, a packaged conda environment was transferred to SuperMUC. The following dependencies were installed:
- numpy
- mpi4py
With the python environment active, we have to feed the right python file directories to the cmake command. Note that -DPYTHON_LIBRARY expects a python shared library. You can likely modify the version to fit what is required.
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON -DPETSC=OFF -DPYTHON=ON -DCMAKE_INSTALL_PREFIX=/path/to/precice -DCMAKE_BUILD_TYPE=RelWithDebInfo .. -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR')+'/libpython2.7.so')") -DNumPy_INCLUDE_DIR=$(python -c "import numpy; print(numpy.get_include())")
make -j 12
make install
After installing, make sure you add the preCICE installation paths to your .bashrc
, so that other programs can find it:
export PRECICE_ROOT="path/to/precice_install"
export PKG_CONFIG_PATH="path/to/precice_install/lib/pkgconfig:${PKG_CONFIG_PATH}"
export CPLUS_INCLUDE_PATH="path/to/precice_install/include:${CPLUS_INCLUDE_PATH}"
export LD_LIBRARY_PATH="path/to/precice_install/lib:${LD_LIBRARY_PATH}"
Then, navigate to the python_future bindings script.
cd /path/to/precice/src/precice/bindings/python_future
Append the following to the head of the file to allow Python2 to run Python3 code. Note that
importing unicode_literals
from future
will cause errors in setuptools
methods as string literals
in code are interpreted as unicode
with this import.
from __future__ import (absolute_import, division,
print_function)
from builtins import (
bytes, dict, int, list, object, range, str,
ascii, chr, hex, input, next, oct, open,
pow, round, super,
filter, map, zip)
Modify mpicompiler_default = "mpic++"
to mpicompiler_default = "mpicxx"
in line 100.
Run the setup file using the default Python 2.7.17.
python setup.py install --user
More information on precice.org. Subscribe to the preCICE mailing list.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Please use "precice.org" for the attribution.
We moved this documentation to the preCICE website. Start looking here.
We moved the description of all tutorials to the preCICE website. Start looking here.
We moved this documentation to the preCICE website. Start looking here.
We moved this documentation to the preCICE website. Start looking here.
- Problems running the tests
- Problems with communication
- Error while loading shared libraries: libprecice.so
- preCICE error messages
- Problems with language bindings
- We moved this documentation to the preCICE website. Start looking here.
- Non-C++ APIs