Cannot build Gromacs due to Cmake complaining about the compiler

GROMACS version: clone from GROMACS / GROMACS · GitLab
GROMACS modification: No

Hi, when trying to build Gromacs on my machine I get the following Cmake warning and error:

CMake Warning at cmake/gmxTestCompilerProblems.cmake:45 (message):
  The versions of the C and C++ compilers do not match (9.4.0 and 7.5.0,
  respectively).  Mixing different C/C++ compilers can cause problems.
Call Stack (most recent call first):
  CMakeLists.txt:340 (gmx_test_compiler_problems)
CMake Error at cmake/gmxTestCompilerProblems.cmake:69 (message):
  GCC version 9 or later required.  Earlier versions don't have full C++17
  support.
Call Stack (most recent call first):
  CMakeLists.txt:340 (gmx_test_compiler_problems)

However:

michele@michele-System-Product-Name:~/gromacs/build$ gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
michele@michele-System-Product-Name:~/gromacs/build$ g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

What am I doing wrong? I build with the following options:
cmake .. -DGMX_GIT_VERSION_INFO=OFF -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=CUDA

It doesn’t seem to pick the compilers up, just supply them on the cmake command line

cmake .. -DGMX_GIT_VERSION_INFO=OFF -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=CUDA -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9

Cheers

Paul

Hi Paul,

Thanks, now it works. It is not a Gromacs problem though: I though “The versions of the C and C++ compilers do not match (9.4.0 and 7.5.0, respectively)” meant I needed gcc at least 9.4.0 and g++ at lest 7.5.0, not both at least 9.4.0. I updated g++ and now I can build.

Thanks again.

Michele

No, it did mean that you need at least g++ 9 for C++17 support per the second error you initially reported.