diff --git a/src/common_io.c b/src/common_io.c
index 8cc25a44093024629c7d8c3faf66646e9c161d2d..e2e29a596701281fb307ab256721d7809d2c1419 100644
--- a/src/common_io.c
+++ b/src/common_io.c
@@ -31,6 +31,9 @@
 #include <stddef.h>
 #include <hdf5.h>
 #include <math.h>
+#ifdef WITH_MPI
+#include <mpi.h>
+#endif
 
 #include "const.h"
 #include "cycle.h"
diff --git a/src/parallel_io.c b/src/parallel_io.c
index bf6119a9b864787af172781d45479e5987167c36..945b8954901e4354bc5597337d40468810039946 100644
--- a/src/parallel_io.c
+++ b/src/parallel_io.c
@@ -23,6 +23,8 @@
 
 #if defined(HAVE_HDF5) && defined(WITH_MPI)
 
+/* Tell HDF5 that we're interested in using shared-memory parallel stuff. */
+#define H5_HAVE_PARALLEL
 
 /* Some standard headers. */
 #include <stdio.h>