TRIQS / mpi

A high-level C++ interface to the Message Passing Interface
https://triqs.github.io/mpi
Apache License 2.0
2 stars 6 forks source link

Missing symbols due to stealthy libmpi_cxx include in OpenMPI #1

Closed phdum closed 4 years ago

phdum commented 4 years ago

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

#define OMPI_SKIP_MPICXX

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: b6e6dd3a280bda534da64536048366a7db77e675

phdum commented 4 years ago

Resolved by #2