# FindMPI error: Failed with exit code 1

**URL:** https://discourse.cmake.org/t/findmpi-error-failed-with-exit-code-1/1616
**Category:** Usage
**Created:** [July 23, 2020, 5:15pm UTC](https://discourse.cmake.org/t/findmpi-error-failed-with-exit-code-1/1616 "2020-07-23T17:15:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/danlipsa/32/87_2.png) [@danlipsa](https://discourse.cmake.org/u/danlipsa)
#### Post date: [July 23, 2020, 5:15pm UTC](https://discourse.cmake.org/t/findmpi-error-failed-with-exit-code-1/1616/1 "2020-07-23T17:15:04Z")

</div>

This is the full error:

```
[96%] Performing configure step for 'paraview'
Not searching for unused variables given on the command line.
-- Could not use git to determine source version, using version 5.8.1-RC2
-- Could NOT find MPI_C (missing: MPI_C_WORKS) 
-- Could NOT find MPI (missing: MPI_C_FOUND C) 
CMake Error at VTK/CMake/vtkModule.cmake:4112 (message):
  Could not find the MPI external dependency.
Call Stack (most recent call first):
  VTK/CMake/vtkModule.cmake:4635 (vtk_module_find_package)
  VTK/Utilities/MPI/CMakeLists.txt:1 (vtk_module_third_party_external)

-- Configuring incomplete, errors occurred!
See also "/ccs/home/danlipsa/projects/paraview-superbuild/rhea-build-egl-5.8.1-RC2/superbuild/paraview/build/CMakeFiles/CMakeOutput.log".
See also "/ccs/home/danlipsa/projects/paraview-superbuild/rhea-build-egl-5.8.1-RC2/superbuild/paraview/build/CMakeFiles/CMakeError.log".
CMake Error at /ccs/home/danlipsa/projects/paraview-superbuild/rhea-build-egl-5.8.1-RC2/superbuild/sb-paraview-configure.cmake:47 (message):
  Failed with exit code 1

make[2]: *** [superbuild/paraview/stamp/paraview-configure] Error 1
make[1]: *** [superbuild/CMakeFiles/paraview.dir/all] Error 2
make: *** [all] Error 2

```

the CMakeError.log file has

```
Building C object CMakeFiles/cmTC_d53fc.dir/test_mpi.c.o
/sw/rhea/gcc/8.4.0/bin/gcc -isystem /autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/openmpi-3.1.4-bmn7or3eq2xi2sol4f7yvlpnwniut7yd/include -fPIC -fPIE -fexceptions -pthread -o CMakeFiles/cmTC_d53fc.dir/test_mpi.c.o -c /ccs/home/danlipsa/projects/paraview-superbuild/rhea-build-egl-5.8.1-RC2/superbuild/paraview/src/VTK/CMake/patches/3.16/FindMPI/test_mpi.c
Linking C executable cmTC_d53fc
/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-4.8.5/cmake-3.15.2-4xbxfsztfb7z2qemxy2dgrsuabbdgifu/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d53fc.dir/link.txt --verbose=1
/sw/rhea/gcc/8.4.0/bin/gcc -fPIC -Wl,-lc -Wl,-lc CMakeFiles/cmTC_d53fc.dir/test_mpi.c.o -o cmTC_d53fc -Wl,-rpath -Wl,/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/hwloc-1.11.11-tqa3ss5jk4cv6z6ymvixjhubmmicslco/lib -Wl,/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/ucx-1.7.0-v4hoykjeatz5yrz2yxyytuykf4buuzbk/lib -Wl,/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/openmpi-3.1.4-bmn7or3eq2xi2sol4f7yvlpnwniut7yd/lib -L/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/hwloc-1.11.11-tqa3ss5jk4cv6z6ymvixjhubmmicslco/lib -L/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/ucx-1.7.0-v4hoykjeatz5yrz2yxyytuykf4buuzbk/lib -pthread /autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/openmpi-3.1.4-bmn7or3eq2xi2sol4f7yvlpnwniut7yd/lib/libmpi.so /autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/openmpi-3.1.4-bmn7or3eq2xi2sol4f7yvlpnwniut7yd/lib/libmpi_cxx.so /autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/openmpi-3.1.4-bmn7or3eq2xi2sol4f7yvlpnwniut7yd/lib/libmpi.so /autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/openmpi-3.1.4-bmn7or3eq2xi2sol4f7yvlpnwniut7yd/lib/libmpi_cxx.so
/autofs/nccs-svm1_sw/rhea/.swci/0-core/opt/spack/20191017/linux-rhel7-x86_64/gcc-8.4.0/ucx-1.7.0-v4hoykjeatz5yrz2yxyytuykf4buuzbk/lib: file not recognized: Is a directory
collect2: error: ld returned 1 exit status

```

If you look carefully at the link line it has:  
`-Wl,-rpath -Wl,dir1 -Wl,dir2 ...`

This seems incorrect. Changing it to `-Wl,-rpath -Wl,dir1 -Wl,-rpath -Wl,dir2 ...` fixes the link error.  
I am using cmake 3.15.2

Any suggestions?  
Thanks,  
Dan

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/danlipsa/32/87_2.png) [@danlipsa](https://discourse.cmake.org/u/danlipsa)
#### Post date: [July 24, 2020, 11:27pm UTC](https://discourse.cmake.org/t/findmpi-error-failed-with-exit-code-1/1616/3 "2020-07-24T23:27:37Z")

</div>

3.18.0 fixes this!
