Error when building on Linux

Hi there,

I was trying to build OGS on a Ubuntu 20.04 machine with the latest source code from GitLab, but meet the following error:

[ 89%] Built target MaterialLib_SolidModels
[ 90%] Building CXX object MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_6_cxx.cxx.o
[ 90%] Building CXX object MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_7_cxx.cxx.o
[ 90%] Linking CXX static library ../../lib/libogs_embedded_python.a
[ 90%] Built target ogs_embedded_python
[ 90%] Building CXX object MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_5_cxx.cxx.o
[ 90%] Building CXX object MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_4_cxx.cxx.o
[ 90%] Building CXX object MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_3_cxx.cxx.o
In file included from /HOME1/users/personal/userid/ogs/build/MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_4_cxx.cxx:37:
/HOME1/users/personal/userid/ogs/source/MaterialLib/MPL/Properties/Enthalpy/WaterVapourLatentHeatWithCriticalTemperature.cpp: In member function ‘virtual MaterialPropertyLib::PropertyDataType MaterialPropertyLib::WaterVapourLatentHeatWithCriticalTemperature::value(const VariableArray&, const ParameterLib::SpatialPosition&, double, double) const’:
/HOME1/users/personal/userid/ogs/source/MaterialLib/MPL/Properties/Enthalpy/WaterVapourLatentHeatWithCriticalTemperature.cpp:64:73: error: no matching function for call to ‘transform_reduce(std::array<double, 8>::const_iterator, std::array<double, 8>::const_iterator, std::array<double, 8>::iterator, double)’
   64 |     return 1000.0 * std::transform_reduce(begin(c), end(c), begin(v), 0.);
      |                                                                         ^
In file included from /usr/shared/packages/gcc-9.2.0/include/c++/9.2.0/numeric:229,
                 from /HOME1/users/personal/userid/ogs/source/MaterialLib/MPL/Properties/Enthalpy/WaterVapourLatentHeatWithCriticalTemperature.cpp:16,
                 from /HOME1/users/personal/userid/ogs/build/MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_4_cxx.cxx:37:
/usr/shared/packages/gcc-9.2.0/include/c++/9.2.0/pstl/glue_numeric_defs.h:35:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::transform_reduce(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Tp)’
   35 | transform_reduce(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
      | ^~~~~~~~~~~~~~~~
/usr/shared/packages/gcc-9.2.0/include/c++/9.2.0/pstl/glue_numeric_defs.h:35:1: note:   template argument deduction/substitution failed:
In file included from /HOME1/users/personal/userid/ogs/build/MaterialLib/CMakeFiles/MaterialLib.dir/Unity/unity_4_cxx.cxx:37:
/HOME1/users/personal/userid/ogs/source/MaterialLib/MPL/Properties/Enthalpy/WaterVapourLatentHeatWithCriticalTemperature.cpp:64:73: note:   deduced conflicting types for parameter ‘_ForwardIterator1’ (‘const double*’ and ‘std::array<double, 8>::value_type*’ {aka ‘double*’})
   64 |     return 1000.0 * std::transform_reduce(begin(c), end(c), begin(v), 0.);

I used the following commands to configure the building:

1, in the build folder

$cmake ../source/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/shared/packages/gcc-9.2.0/bin/g++ -DCMAKE_C_COMPILER=/usr/shared/packages/gcc-9.2.0/bin/gcc -DCMAKE_CXX_STANDARD=20

2, in the build folder

make -j 3

Could you please give me a hint on what goes wrong here?

Regards,
Chao

Hi Chao,

would you post the full error message as text (file)?

– d

Hi Dmitri :smile:

Of course, I put all of my screen output in this gist, as the forum doesn’t allow a new user to upload attachment.

If you roll down to the bottom of the text file, you may see the error message.

Chao

Seems to be a bug in gcc-9.2. Compiles with gcc-9.3:

Tested with compiler explorer link: middle pane failing compilation 9.2, right pane successful 9.3. Also works with gcc-9.4 and clang-10.

Can you choose a different compiler / compiler version?
If not, I can choose a different algorithm for the named compilers as workaround.

– d

Hi Dima,

Thanks VERY much for your experiment.

I’ll talk to our IT guy tomorrow and see he could help build a gcc-9.3/9.4 in our global environment. (I’m quite sure he is happy to help) If not, I’ll build a local one and there is no problem with this.

I’ll keep you updated.

Chao

In the meantime you can replace transform_reduce with inner_product: essentially the same algorithm, or even remove the particular material model…

– d

Thank you, Dima.

I can confirm with you now the building goes smoothly with gcc-9.4.

Chao

Thanks Chao!

I’ll add a workaround for the gcc < 9.3 so other’s don’t suffer :wink:

– d