diff --git a/lib/DiffractionImage/Bruker/FRM_LIB.c b/lib/DiffractionImage/Bruker/FRM_LIB.c
index bfda882..f821e04 100755
--- a/lib/DiffractionImage/Bruker/FRM_LIB.c
+++ b/lib/DiffractionImage/Bruker/FRM_LIB.c
@@ -38,6 +38,8 @@ FRM_LIB: Routines for reading, writing, and handling frame files.
 #include "sys/types.h"  /* _open, etc. */
 #include "sys/stat.h"   /* _open, etc. */
 
+#include <unistd.h>
+
 #ifndef _MSC_VER
 int min(int a, int b)
 	{
diff --git a/lib/DiffractionImage/MAR/mar300_header.c b/lib/DiffractionImage/MAR/mar300_header.c
index 1a933de..1c40c32 100755
--- a/lib/DiffractionImage/MAR/mar300_header.c
+++ b/lib/DiffractionImage/MAR/mar300_header.c
@@ -23,6 +23,9 @@
  */
 #include "mar300_header.h"
 
+#include <sys/types.h>
+#include <unistd.h>
+
 /*
  * Local functions
  */
diff --git a/lib/DiffractionImage/MAR/mar345_header.c b/lib/DiffractionImage/MAR/mar345_header.c
index a8351ea..16d0f7b 100755
--- a/lib/DiffractionImage/MAR/mar345_header.c
+++ b/lib/DiffractionImage/MAR/mar345_header.c
@@ -32,6 +32,9 @@
  */
 #include "mar345_header.h"
 
+#include <sys/types.h>
+#include <unistd.h>
+
 /*
  * Definitions
  */
diff --git a/lib/DiffractionImage/MAR/nb_header.c b/lib/DiffractionImage/MAR/nb_header.c
index 07f2741..6364ca4 100755
--- a/lib/DiffractionImage/MAR/nb_header.c
+++ b/lib/DiffractionImage/MAR/nb_header.c
@@ -20,6 +20,8 @@
 #include <io.h>
 #endif
 
+#include <sys/types.h>
+#include <unistd.h>
 /*
  * mar software include files
  */
diff --git a/lib/DiffractionImage/MAR/swap.c b/lib/DiffractionImage/MAR/swap.c
index 443bb8c..0d96b3f 100755
--- a/lib/DiffractionImage/MAR/swap.c
+++ b/lib/DiffractionImage/MAR/swap.c
@@ -10,6 +10,9 @@
  *
  **********************************************************************/
 
+#define _XOPEN_SOURCE
+#include <unistd.h>
+
 void swaplong();
 void swapshort();
 
diff --git a/lib/ccif/f_interface.c b/lib/ccif/f_interface.c
index 0f6a6b7..a09dc48 100755
--- a/lib/ccif/f_interface.c
+++ b/lib/ccif/f_interface.c
@@ -25,6 +25,7 @@
 ********************************************************************/
 
 #include "stdpccts.h"
+#include <sys/mman.h>
 
 /* This file is terribly organised, and badly needs re-doing. There is probably
  * scope for splitting this into three modules:
diff --git a/lib/src/ccp4_general_f.c b/lib/src/ccp4_general_f.c
index 8b5d04f..74ee3f7 100755
--- a/lib/src/ccp4_general_f.c
+++ b/lib/src/ccp4_general_f.c
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
+#include <time.h>
 #include "ccp4_errno.h"
 #include "ccp4_fortran.h"
 #include "ccp4_parser.h"
diff --git a/lib/src/ccp4_program.c b/lib/src/ccp4_program.c
index 3e83d4d..bb3e975 100755
--- a/lib/src/ccp4_program.c
+++ b/lib/src/ccp4_program.c
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include "ccp4_program.h"
 #include "ccp4_parser.h"
 #include "ccp4_utils.h"
diff --git a/lib/src/fsplit.c b/lib/src/fsplit.c
index ee8af24..c6fb3cd 100755
--- a/lib/src/fsplit.c
+++ b/lib/src/fsplit.c
@@ -50,6 +50,7 @@ static char sccsid[] = "@(#)fsplit.c	5.5 (Berkeley) 3/12/91";
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
 /*
  *	usage:		fsplit [-e efile] ... [file]
diff --git a/src/clipper_progs/src/pirate/compress42.c b/src/clipper_progs/src/pirate/compress42.c
index ea52e96..30dbd56 100755
--- a/src/clipper_progs/src/pirate/compress42.c
+++ b/src/clipper_progs/src/pirate/compress42.c
@@ -142,6 +142,7 @@
 #include	<sys/types.h>
 #include	<sys/stat.h>
 #include	<errno.h>
+#include	<unistd.h>
 
 #ifdef DIRENT
 #	include	<dirent.h>
diff --git a/src/mtz2cif_/mtz2cif.c b/src/mtz2cif_/mtz2cif.c
index e224430..c7b82f4 100755
--- a/src/mtz2cif_/mtz2cif.c
+++ b/src/mtz2cif_/mtz2cif.c
@@ -28,6 +28,7 @@
 #include "cmtzlib.h"
 #include "ccp4_parser.h"
 #include "ccp4_general.h"
+#include "ccp4_program.h"
 #include "csymlib.h"
 #include "mtz2cif_lib.h"
 
diff --git a/x-windows/XCCPJIFFY/xplot84driver.c b/x-windows/XCCPJIFFY/xplot84driver.c
index 67e0bf1..76526ab 100755
--- a/x-windows/XCCPJIFFY/xplot84driver.c
+++ b/x-windows/XCCPJIFFY/xplot84driver.c
@@ -11,6 +11,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
+#include <stdlib.h>
 
 #include <X11/StringDefs.h>
 #include <X11/Intrinsic.h>
