diff --git a/src/xpdev/rwlockwrap.h b/src/xpdev/rwlockwrap.h
index 9ebdf27f7fd27f14855bd9f77a2c08b581e33f53..73446426ad1ab959a71785cbfa7196391a66ea9c 100644
--- a/src/xpdev/rwlockwrap.h
+++ b/src/xpdev/rwlockwrap.h
@@ -1,6 +1,10 @@
 #ifndef RWLOCKWRAP_H
 #define RWLOCKWRAP_H
 
+#ifndef NDEBUG
+#include <assert.h>
+#endif
+
 #if defined(__unix__)
 
 #include <pthread.h>
diff --git a/src/xpdev/threadwrap.h b/src/xpdev/threadwrap.h
index a2b14212d9072e8cdb169652cdcb8476bde05c8e..c31579ab588fc16e648f11e5399396032620be79 100644
--- a/src/xpdev/threadwrap.h
+++ b/src/xpdev/threadwrap.h
@@ -40,6 +40,10 @@
 #endif
 #endif
 
+#ifndef NDEBUG
+#include <assert.h>
+#endif
+
 #if defined(__cplusplus)
 extern "C" {
 #endif