dolfinx icon indicating copy to clipboard operation
dolfinx copied to clipboard

Missing header

Open matsievskiysv opened this issue 2 years ago • 1 comments

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

matsievskiysv avatar Aug 14 '22 12:08 matsievskiysv

Just checked, the same error is present in master.

matsievskiysv avatar Aug 14 '22 12:08 matsievskiysv

What c++ compiler?

chrisrichardson avatar Aug 16 '22 08:08 chrisrichardson

Can you post the errors?

chrisrichardson avatar Aug 16 '22 09:08 chrisrichardson

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.

chrisrichardson avatar Aug 16 '22 11:08 chrisrichardson

Compiler: g++ (Debian 12.1.0-7) 12.1.0 Error log: err.log

matsievskiysv avatar Aug 16 '22 11:08 matsievskiysv

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

matsievskiysv avatar Aug 16 '22 11:08 matsievskiysv

I get the error building with spack using gcc-12.1.0

ma595 avatar Aug 17 '22 10:08 ma595

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.

drew-parsons avatar Aug 17 '22 14:08 drew-parsons

Fixed in #2323

jorgensd avatar Aug 17 '22 15:08 jorgensd