# cmake 3.23.2 - Error: Could not find MPI\_C on Macbook Pro os 10.13.6; elmerfem, FindMPI

**URL:** https://discourse.cmake.org/t/cmake-3-23-2-error-could-not-find-mpi-c-on-macbook-pro-os-10-13-6-elmerfem-findmpi/6161
**Category:** Usage
**Tags:** os:macos
**Created:** [July 27, 2022, 3:04pm UTC](https://discourse.cmake.org/t/cmake-3-23-2-error-could-not-find-mpi-c-on-macbook-pro-os-10-13-6-elmerfem-findmpi/6161 "2022-07-27T15:04:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tom-Bertin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tom-bertin/32/2628_2.png) [@Tom-Bertin](https://discourse.cmake.org/u/Tom-Bertin)
#### Post date: [July 27, 2022, 3:04pm UTC](https://discourse.cmake.org/t/cmake-3-23-2-error-could-not-find-mpi-c-on-macbook-pro-os-10-13-6-elmerfem-findmpi/6161/1 "2022-07-27T15:04:54Z")

</div>

First of all: it’s the first time I’m filing an issue here. I also don’t know if I’m in the right place here for asking help for this issue. I also am NOT an advanced user of cmake, compilers, macports, etc. I just wanted to install a seemingly simple open-source program for doing Finite Element Analysis, but it turned out not as straight-forward as it seemed. Apologies beforehand for any stupid questions.

**Problem**

While trying to cmake and build a program called ‘_elmerfem_’, I get the following error:

```auto
CMake Error at cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
    Could NOT find MPI_C (missing: MPI_C_LIBRARIES MPI_C_INCLUDE_PATH)
Call Stack (most recent call first):
    cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
    cmake/Modules/FindMPI.cmake:615 (find_package_handle_standard_args)
    CMakeLists.txt:254 (FIND_PACKAGE)

```

I tried many times including locations for this package via `-DCMAKE_PREFIX_PATH=\<relevant_location>`, but this didn’t work. The commands below are (some of) the ones I tried:

```auto
cmake -DWITH_ELMERGUI:BOOLEAN=TRUE -DWITH_OpenMP:BOOLEAN=TRUE -DWITH_MPI:BOOLEAN=TRUE -DCMAKE_PREFIX_PATH=/opt/local/bin/mpiexec.hydra-mpich-mp -DCMAKE_INSTALL_PREFIX=../install ../elmerfem

```

```auto
cmake -DWITH_ELMERGUI:BOOLEAN=TRUE -DWITH_OpenMP:BOOLEAN=TRUE -DWITH_MPI:BOOLEAN=TRUE -DCMAKE_PREFIX_PATH=/opt/local/bin/mpiexec -DCMAKE_INSTALL_PREFIX=../install ../elmerfem

```

```auto
cmake -DWITH_ELMERGUI:BOOLEAN=TRUE -DWITH_OpenMP:BOOLEAN=TRUE -DWITH_MPI:BOOLEAN=TRUE -DCMAKE_PREFIX_PATH=/opt/local/bin/ -DCMAKE_INSTALL_PREFIX=../install ../elmerfem

```

**Question:**

1. How do I point cmake to the relevant compilers, libraries, and packages it needs? Have I done something wrong, or overlooked something?
2. How do I figure out where the problem is situated? Meaning, is it a fault on cmake’s side, or something in the CMakeLists.txt, or on Macports’ side, OSX, Xcode, … ?

**My system**

- Macbook Pro late 2011
- OSX 10.13.6
- Packages installed via Macports v2.7.2 (compilers, libs, …)
- Xcode 10.1

**Other possibly relevant things:**

- Previously I also had trouble with cmake finding the C-, CXX-, and Fortran-compilers. After a lot of searching, trying things out, failing and cursing everything to the moon, I ended up changing the CMakeLists.txt manually. I am aware that this is actually ‘not done’, but at least it worked. The relevant compilers where indeed found by cmake.
- all packages and libraries needed are installed via ‘_Macports_’. The installation-guide of ‘_elmerfem_’ is written for Homebrew instead of Macports. I’m guessing all the included installation-files are all aimed at locations typically used by Homebrew, and I probably need to adapt them for usage with Macports. Or is that stupid idea?
- Previously I tried building/compiling ‘_elmerfem_’ (also with cmake) on a Fedora 36 system. I got the same error for MPI\_C.
- I got this kind of errors a lot, for MPI, MUMPS, and other libraries. This was the case on OSX as well as on Fedora36.

Many thanks in advance, and best regards,

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [August 2, 2022, 11:09am UTC](https://discourse.cmake.org/t/cmake-3-23-2-error-could-not-find-mpi-c-on-macbook-pro-os-10-13-6-elmerfem-findmpi/6161/2 "2022-08-02T11:09:57Z")

</div>

Have you tried `-DCMAKE_PREFIX_PATH=/opt/local`? A prefix here is what you might pass to `--prefix` in an autoconf build (basically “where to put all built things for use”). Homebrew likes `/opt/local` for this. Usually, `bin` is a subdirectory with executables, so you want its parent directory.

You can pass `--debug-find` to CMake to get an idea of where it is looking for stuff.
