dolfinx
dolfinx copied to clipboard
Missing header
I have a bunch of errors during build of DolfinX due to missing #include <algorithm>
header in dolfinx/cpp/dolfinx/common/MPI.h
file. All errors complain about missing functions from std
namespace. After adding this header, errors were gone.
Full installation script:
#!/usr/bin/env bash
set -e
SOURCE_DIR=$(realpath $(dirname $0))
BUILD_DIR=$SOURCE_DIR/build-dir
INSTALL_DIR=/opt/dolfinx
BASIX_COMMIT=v0.5.0
DOLFIN_COMMIT=v0.5.0
UFL_COMMIT=2022.2.0
FFCX_COMMIT=v0.5.0
git clone https://github.com/FEniCS/basix.git $SOURCE_DIR/basix
git -C $SOURCE_DIR/basix checkout $BASIX_COMMIT
git clone https://github.com/FEniCS/dolfinx.git $SOURCE_DIR/dolfinx
git -C $SOURCE_DIR/dolfinx checkout $DOLFIN_COMMIT
git clone https://github.com/FEniCS/ufl.git $SOURCE_DIR/ufl
git -C $SOURCE_DIR/ufl checkout $UFL_COMMIT
git clone https://github.com/FEniCS/ffcx.git $SOURCE_DIR/ffcx
git -C $SOURCE_DIR/ffcx checkout $FFCX_COMMIT
scalar_type=complex
CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH:$INSTALL_PATH/lib/cmake/:$INSTALL_DIR/share/cmake/"
PETSC_DIR="/usr/lib/petscdir/petsc-$scalar_type"
SLEPC_DIR="/usr/lib/slepcdir/slepc-$scalar_type"
PETSC_ARCH="linux-gnu-$scalar_type-64"
PYTHONPATH="$PETSC_DIR/lib/python3/dist-packages:$SLEPC_DIR/lib/python3/dist-packages"
PKG_CONFIG_PATH="$PETSC_DIR/lib/pkgconfig:$PKG_CONFIG_PATH"
LD_LIBRARY_PATH="$PETSC_DIR/lib:$LD_LIBRARY_PATH"
# Basix
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-B $BUILD_DIR -S $SOURCE_DIR/basix/cpp
cmake --build $BUILD_DIR -j$(nproc)
sudo cmake --install $BUILD_DIR
pushd $SOURCE_DIR/basix
python3 setup.py bdist_wheel
pip3 install --user ./dist/*.whl
popd
# UFL
pushd $SOURCE_DIR/ufl
python3 setup.py bdist_wheel
pip3 install --user ./dist/*.whl
popd
# FFCX
pushd $SOURCE_DIR/ffcx
python3 setup.py bdist_wheel
pip3 install --user ./dist/*.whl
popd
# DolfinX
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-B $BUILD_DIR -S $SOURCE_DIR/dolfinx/cpp
cmake --build $BUILD_DIR -j$(nproc)
sudo cmake --install $BUILD_DIR
source $INSTALL_DIR/lib/dolfinx/dolfinx.conf
# MPI
pip3 install --user mpi4py
# PETSc
pip3 install --user petsc4py
# SLEPc
pip3 install --user slepc4py
pushd $SOURCE_DIR/dolfinx/python
python3 setup.py bdist_wheel
pip3 install --user ./dist/*.whl
popd
CMake cache: CMakeCache.txt
OS: Linux 5.18.0-2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.5-1 (2022-06-16) x86_64 GNU/Linux
Just checked, the same error is present in master.
What c++ compiler?
Can you post the errors?
Maybe it should have #include <algorithm>
since std::sort
is used in MPI.h
- strange that this did not come up before, though, and is not an issue on the CI system.
Compiler: g++ (Debian 12.1.0-7) 12.1.0 Error log: err.log
strange that this did not come up before, though, and is not an issue on the CI system
Maybe template expansion rules slightly changed with new g++ update
I get the error building with spack using gcc-12.1.0
I'm getting the same error in a debian build. Also using gcc 12.1.0, so the change in behaviour is likely due to changes in gcc 12 compared to gcc 11.
The solution (add #include <algorithm>
) is on record at https://stackoverflow.com/questions/31159302/ . It fixes the problem well enough.
Fixed in #2323