diff --git a/lib/memdebug.c b/lib/memdebug.c
index a92207f64dec5c373496092a509dcf9960e79cb5..72fc99557c5f6e2c30c883b56006d03340300f3c 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -58,6 +58,10 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 /* DONT include memdebug.h here! */
 
 /*