diff --git a/src/cooling/EAGLE/cooling.h b/src/cooling/EAGLE/cooling.h
index 99d0c7d7cc1a99ba21fa21fc0f46b26f4a3203d3..62d1cc9b72681fe96c901185a10efe5523b206e3 100644
--- a/src/cooling/EAGLE/cooling.h
+++ b/src/cooling/EAGLE/cooling.h
@@ -37,6 +37,8 @@
 #include "physical_constants.h"
 #include "units.h"
 
+#ifdef HAVE_HDF5
+
 /**
  * @brief Writes the current model of SPH to the file
  * @param h_grpsph The HDF5 group in which to write
@@ -46,6 +48,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 
   io_write_attribute_s(h_grpsph, "Cooling Model", "EAGLE");
 }
+#endif
 
 /**
  * @brief Apply the cooling function to a particle.
diff --git a/src/cooling/const_du/cooling.h b/src/cooling/const_du/cooling.h
index 83698c06ffe8f5dfdf14b140d3befe5e72e0f6d0..25aa974e47b277d0dfcc21077e5041a49e8168c8 100644
--- a/src/cooling/const_du/cooling.h
+++ b/src/cooling/const_du/cooling.h
@@ -44,6 +44,8 @@
 #include "physical_constants.h"
 #include "units.h"
 
+#ifdef HAVE_HDF5
+
 /**
  * @brief Writes the current model of SPH to the file
  * @param h_grpsph The HDF5 group in which to write
@@ -53,6 +55,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 
   io_write_attribute_s(h_grpsph, "Cooling Model", "Constant du/dt");
 }
+#endif
 
 /**
  * @brief Apply the cooling function to a particle.
diff --git a/src/cooling/const_lambda/cooling.h b/src/cooling/const_lambda/cooling.h
index af648b904356dc7ceea68a7474426347cdfce4d0..a402b749300e64ef79253764c402d41f5a214d82 100644
--- a/src/cooling/const_lambda/cooling.h
+++ b/src/cooling/const_lambda/cooling.h
@@ -37,6 +37,8 @@
 #include "physical_constants.h"
 #include "units.h"
 
+#ifdef HAVE_HDF5
+
 /**
  * @brief Writes the current model of SPH to the file
  * @param h_grpsph The HDF5 group in which to write
@@ -46,6 +48,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 
   io_write_attribute_s(h_grpsph, "Cooling Model", "Constant Lambda");
 }
+#endif
 
 /**
  * @brief Calculates du/dt in code units for a particle.
diff --git a/src/cooling/grackle/cooling.h b/src/cooling/grackle/cooling.h
index b7a09f1907604f06d0d5534022228f9ab159a0ff..d1da52300121ca56feea4114d74322120bd501ce 100644
--- a/src/cooling/grackle/cooling.h
+++ b/src/cooling/grackle/cooling.h
@@ -42,6 +42,8 @@
 #define GRACKLE_NPART 1
 #define GRACKLE_RANK 3
 
+#ifdef HAVE_HDF5
+
 /**
  * @brief Writes the current model of SPH to the file
  * @param h_grpsph The HDF5 group in which to write
@@ -51,6 +53,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 
   io_write_attribute_s(h_grpsph, "Cooling Model", "Grackle");
 }
+#endif
 
 /**
  * @brief Sets the cooling properties of the (x-)particles to a valid start
diff --git a/src/cooling/none/cooling.h b/src/cooling/none/cooling.h
index 4715c06f9fe5db0af78f95d43e37a064688c6ee3..a1cc6491115a38d6971a57603fef413c35b52027 100644
--- a/src/cooling/none/cooling.h
+++ b/src/cooling/none/cooling.h
@@ -37,6 +37,8 @@
 #include "physical_constants.h"
 #include "units.h"
 
+#ifdef HAVE_HDF5
+
 /**
  * @brief Writes the current model of SPH to the file
  * @param h_grpsph The HDF5 group in which to write
@@ -46,6 +48,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
 
   io_write_attribute_s(h_grpsph, "Cooling Model", "None");
 }
+#endif
 
 /**
  * @brief Apply the cooling function to a particle.