--- a/glib/gatomic.c
+++ b/glib/gatomic.c
@@ -881,6 +881,7 @@ g_atomic_pointer_compare_and_exchange (v
 #endif /* DEFINE_WITH_WIN32_INTERLOCKED */
 
 #ifdef DEFINE_WITH_MUTEXES
+#include "gthread.h"
 /* We have to use the slow, but safe locking method */
 static GMutex *g_atomic_mutex;