# Cannot build Gromacs due to Cmake complaining about the compiler

**URL:** <https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886>\
**Category:** User discussions\
**Tags:** cmake-error\
**Created:** [September 27, 2022, 9:04am UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886 "2022-09-27T09:04:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichelePellegrino](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/michelepellegrino/32/628_2.png) [@MichelePellegrino](https://gromacs.bioexcel.eu/u/MichelePellegrino)\
**Post date:** [September 27, 2022, 9:04am UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886/1 "2022-09-27T09:04:58Z")

</div>

GROMACS version: clone from [GROMACS / GROMACS · GitLab](https://gitlab.com/gromacs/gromacs.git)  
GROMACS modification: No

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

```auto
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)

```

```auto
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:

```auto
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.

```

```auto
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`

---

<div class="post-metadata">

**Author:** ![pbauer](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/pbauer/32/13_2.png) [@pbauer](https://gromacs.bioexcel.eu/u/pbauer)\
**Post date:** [September 27, 2022, 9:16am UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886/2 "2022-09-27T09:16:41Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![MichelePellegrino](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/michelepellegrino/32/628_2.png) [@MichelePellegrino](https://gromacs.bioexcel.eu/u/MichelePellegrino)\
**Post date:** [September 27, 2022, 9:24am UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886/3 "2022-09-27T09:24:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pszilard](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/pszilard/32/21_2.png) [@pszilard](https://gromacs.bioexcel.eu/u/pszilard)\
**Post date:** [September 27, 2022, 2:16pm UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886/4 "2022-09-27T14:16:00Z")

</div>

> [@MichelePellegrino](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![bryancantero](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@bryancantero](https://gromacs.bioexcel.eu/u/bryancantero)\
**Post date:** [September 3, 2023, 12:44am UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886/5 "2023-09-03T00:44:14Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![al42and](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/al42and/32/1393_2.png) [@al42and](https://gromacs.bioexcel.eu/u/al42and)\
**Post date:** [September 4, 2023, 10:29am UTC](https://gromacs.bioexcel.eu/t/cannot-build-gromacs-due-to-cmake-complaining-about-the-compiler/4886/6 "2023-09-04T10:29:14Z")

</div>

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](https://manual.gromacs.org/current/user-guide/known-issues.html#cannot-find-a-working-standard-library-error-with-rocm-clang)?
