Prerequisites
Having a OpenMPI version that was compiled with cxx bindings.
Description
Certain versions of OpenMPI (including the most recent stable 4.0.x) still include cxx bindings, which can be optionally compiled to a separate library libmpi_cxx. Depending on the linux distribution these may or may not be built by default.
If they were build, the mpi.h header (superficially "c only") will by default also include all the cxx bindings.
From ompi/mpi.h (https://github.com/open-mpi/ompi/blob/v4.0.x/ompi/include/mpi.h.in):
#if !defined(OMPI_SKIP_MPICXX) && OMPI_BUILD_CXX_BINDINGS && !OMPI_BUILDING
#if defined(c_plusplus) || defined(__cplusplus)
#include "openmpi/ompi/mpi/cxx/mpicxx.h"
#endif
#endif
Then when we try to compile a program against our own mpi_c target, it complains of the unresolved symbols (since we are not linking against libmpi_cxx).
The solution would be to include
Somewhere before we import the mpi.h header.
The only question is: do we want to do this simply as a global definition in a header. Or do this in cmake, so that that recognizes if this will be a problem and adds the appropriate flag.
Finally, MPICH2 also cxx bindings. I did not check if they could cause problem there, but a similar issue could arise.
Versions
Current unstable branch: b6e6dd3