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.

Hi guys, I’m trying to install Gromacs as well, but I’m having this,

make … -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=SYCL -DGMX_SYCL_HIPSYCL=on
CMake Error at cmake/FindLibStdCpp.cmake:182 (message):
The C++ compiler cannot find a working standard library. The compiler was
not trying to use libstdc++. The GROMACS build system cannot handle this
case. Please use a working C++17 compiler and standard library.
Call Stack (most recent call first):
CMakeLists.txt:90 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/bryan/Descargas/gromacs-2023.2/build/CMakeFiles/CMakeOutput.log”.
See also “/home/bryan/Descargas/gromacs-2023.2/build/CMakeFiles/CMakeError.log”.

Looking for the cmakeerror file,

The output was:
1
/usr/bin/ld: no se puede encontrar -lstdc++: No existe el archivo o el directorio
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Checking whether the ASM compiler is GNU using “–version” did not match “(GNU assembler)|(GCC)|(Free Software Foundation)”:
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: /root/git/llvm-vanilla/build/CMakeFiles/CMakeTmp

Any comments may help, thank you!

Hi! Have you tried sudo apt install libstdc++-12-dev, as described in https://manual.gromacs.org/current/user-guide/known-issues.html#cannot-find-a-working-standard-library-error-with-rocm-clang?