Open MPI broken after upgrading to Mac OS X 10.14.6

After upgrading to 10.14.6, openmpi no longer works on my MacBook Air (2019). Attempting to run any related commands mpicxx or mpiexec produce the error

    dyld: Library not loaded: /usr/local/opt/libevent/lib/libevent-2.1.6.dylib

I reinstalled the latest versions of openmpi (4.0.1) and libevent (2.1.11) (this wasn't necessary in the previous openmpi installation, but openmpi could not make without it). However, even though the installation of openmpi was successful, it still seems to be still corrupted and fails with the same error as above when running mpiexec.

Any ideas what is causing this, or how to get this working again?


Open MPI 4.0.3 is now available from homebrew. brew upgrade openmpi will solve the problem.


As explained in the Building Open MPI FAQ, this error can happen when a number of factors occur together:

  • If Open MPI's configure script chooses to use an "external" installation of hwloc and/or Libevent (i.e., outside of Open MPI's source tree).
  • If Open MPI's configure script chooses C and Fortran compilers from different suites/installations.

Put simply: if the default search library search paths differ between the C and Fortran compiler suites, the C linker may find a system-installed libhwloc and/or libevent, but the Fortran linker may not.

This tends to happen more frequently on macOS because it is common for Homebrew or MacPorts to install:

  • hwloc and/or Libevent
  • gcc and gfortran

There are a few different possible solutions to this issue:

  1. The best solution is to always ensure that Open MPI uses a C and Fortran compiler from the same suite/installation. This will ensure that both compilers/linkers will use the same default library search paths, and all behavior should be consistent.

    For example, the following instructs Open MPI's configure script to use Homebrew's gcc-9 for the C compiler by specifying an absolute path for it (and for the Fortran compiler):

    $ ./configure CC=/usr/local/bin/gcc-9 FC=/usr/local/bin/gfortran ...
    

    Note that this will likely cause configure to not find the Homebrew-installed hwloc, and instead fall back to using the bundled hwloc in the Open MPI source tree.

  2. Alternatively, you can simply force configure to select the bundled versions of hwloc and libevent, which avoids the issue altogether:

    $ ./configure --with-hwloc=internal --with-libevent=internal ...
    
  3. Finally, you can tell configure exactly where to find the external hwloc library. This can have some unintended consequences, however, because it will prefix both the C and Fortran linker's default search paths with /usr/local/lib:

    $ ./configure --with-hwloc-libdir=/usr/local/lib ...
    

Be sure to also see this FAQ question for more information about using the bundled hwloc and/or Libevent vs. system-installed versions.