# CMake Build Error: Could NOT find MPI\_CXX

**URL:** https://discourse.cmake.org/t/cmake-build-error-could-not-find-mpi-cxx/14402
**Category:** Usage
**Tags:** os:linux
**Created:** [July 21, 2025, 10:59am UTC](https://discourse.cmake.org/t/cmake-build-error-could-not-find-mpi-cxx/14402 "2025-07-21T10:59:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Eledmunds](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/df788c/32.png) [@Eledmunds](https://discourse.cmake.org/u/Eledmunds)
#### Post date: [July 21, 2025, 10:59am UTC](https://discourse.cmake.org/t/cmake-build-error-could-not-find-mpi-cxx/14402/1 "2025-07-21T10:59:29Z")

</div>

Hi there,

I am trying to create a docker image with a GPU-enabled version of LAMMPS. In the Dockerfile, I am trying to use CMake to build LAMMPS but am facing an error where by CMake cannot find MPI\_CXX.

The error specifically is:

```auto
------
 > [8/11] RUN cmake "/opt/lammps/cmake" -D LAMMPS_SOURCE_DIR="/opt/lammps" -D CMAKE_BUILD_TYPE=Release -C "/opt/lammps/cmake/presets/most.cmake" -D BUILD_SHARED_LIBS=ON -D PKG_PYTHON=ON -D PKG_OPENMP=ON -D BUILD_MPI=ON -D BUILD_OMP=ON -D PKG_KOKKOS=ON -D Kokkos_ENABLE_SERIAL=ON -D Kokkos_ENABLE_CUDA=ON -D Kokkos_ENABLE_OPENMP=ON -D Kokkos_ARCH_NATIVE=ON -D Kokkos_ARCH_ADA89=ON -D CMAKE_CXX_COMPILER=$(which mpicxx) -D CMAKE_CUDA_COMPILER=$(which nvcc) -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -D CMAKE_CUDA_HOST_COMPILER=$(which g++) -D CMAKE_CUDA_STANDARD=17:
1.024 CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
1.024 Could NOT find MPI (missing: MPI_CXX_FOUND CXX)
1.024 Call Stack (most recent call first):
1.024 /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
1.024 /usr/share/cmake-3.28/Modules/FindMPI.cmake:1837 (find_package_handle_standard_args)
1.024 CMakeLists.txt:393 (find_package)
1.024 
1.024 
1.024 -- Could NOT find MPI_CXX (missing: MPI_CXX_WORKS) 
1.024 -- Configuring incomplete, errors occurred!
------

```

I think that I’ve installed it correctly, as earlier in the log file I can check the version and the location of some relevant packages:

```auto
#6 24.84 --- Checking mpicxx ---
#6 24.84 /usr/bin/mpicxx
#6 24.85 g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
#6 24.85 Copyright (C) 2023 Free Software Foundation, Inc.
#6 24.85 This is free software; see the source for copying conditions. There is NO
#6 24.85 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#6 24.85 
#6 24.85 --- Checking nvcc ---
#6 24.85 /usr/local/cuda/bin/nvcc
#6 24.85 nvcc: NVIDIA (R) Cuda compiler driver
#6 24.85 Copyright (c) 2005-2025 NVIDIA Corporation
#6 24.85 Built on Tue_May_27_02:21:03_PDT_2025
#6 24.85 Cuda compilation tools, release 12.9, V12.9.86
#6 24.85 Build cuda_12.9.r12.9/compiler.36037853_0
#6 24.85 --- Checking CMake ---
#6 24.85 /usr/bin/cmake
#6 24.86 cmake version 3.28.3

```

I’m a bit confused as to what is going on because it almost seems to me like CMake actually can find it as per the output below:

```auto
#12 0.333 -- The CXX compiler identification is GNU 13.3.0
#12 0.605 -- The C compiler identification is GNU 13.3.0
#12 0.620 -- Detecting CXX compiler ABI info
#12 0.696 -- Detecting CXX compiler ABI info - done
#12 0.702 -- Check for working CXX compiler: /usr/bin/mpicxx - skipped
#12 0.702 -- Detecting CXX compile features
#12 0.703 -- Detecting CXX compile features - done
#12 0.709 -- Detecting C compiler ABI info
#12 0.772 -- Detecting C compiler ABI info - done
#12 0.777 -- Check for working C compiler: /usr/bin/cc - skipped
#12 0.777 -- Detecting C compile features
#12 0.777 -- Detecting C compile features - done
#12 0.783 -- Found Git: /usr/bin/git (found version "2.43.0") 
#12 0.783 -- Appending /usr/local/cuda/lib64/stubs to CMAKE_LIBRARY_PATH: /usr/local/cuda/lib64/stubs
#12 0.784 -- Running check for auto-generated files from make-based build system
#12 1.024 CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
#12 1.024 Could NOT find MPI (missing: MPI_CXX_FOUND CXX)
#12 1.024 Call Stack (most recent call first):
#12 1.024 /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
#12 1.024 /usr/share/cmake-3.28/Modules/FindMPI.cmake:1837 (find_package_handle_standard_args)
#12 1.024 CMakeLists.txt:393 (find_package)
#12 1.024 
#12 1.024

```

Hopefully this is the right place to post this issue. Any advice would be much appreciated!

Thanks in advance,

---

<div class="post-metadata">

### Author: ![Enguang\_Fu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/enguang_fu/32/5918_2.png) [@Enguang\_Fu](https://discourse.cmake.org/u/Enguang_Fu)
#### Post date: [November 20, 2025, 10:21pm UTC](https://discourse.cmake.org/t/cmake-build-error-could-not-find-mpi-cxx/14402/2 "2025-11-20T22:21:32Z")

</div>

Hi,

The issue you encountered looks very similar to what posted at [CMake fails at finding working MPI when building with Kokkos+CUDA in Docker - #3 by edobld - LAMMPS Installation - Materials Science Community Discourse](https://matsci.org/t/cmake-fails-at-finding-working-mpi-when-building-with-kokkos-cuda-in-docker/64010/3).

In short, there is one possible contamination in flags in the CMakeLists.txt file in LAMMPS. Commenting that out solves the problem.
