diff -ru a/Imlib/load.c b/Imlib/load.c
--- a/Imlib/load.c	2015-06-21 03:21:07.000000000 +0200
+++ b/Imlib/load.c	2015-06-21 03:16:28.000000000 +0200
@@ -443,7 +443,11 @@
   fd = fileno(f);
   /* Apparently rewind(f) isn't sufficient */
   lseek(fd, (long) 0, 0);
+#if GIFLIB_MAJOR >= 5
+  gif = DGifOpenFileHandle(fd, NULL);
+#else
   gif = DGifOpenFileHandle(fd);
+#endif
 
   if (!gif)
     return NULL;
diff -ru a/gdk_imlib/io-gif.c b/gdk_imlib/io-gif.c
--- a/gdk_imlib/io-gif.c	2002-03-04 18:06:29.000000000 +0100
+++ b/gdk_imlib/io-gif.c	2015-06-21 03:15:40.000000000 +0200
@@ -30,7 +30,11 @@
   fd = fileno(f);
   /* Apparently rewind(f) isn't sufficient */
   lseek(fd, (long) 0, 0);
+#if GIFLIB_MAJOR >= 5
+  gif = DGifOpenFileHandle(fd, NULL);
+#else
   gif = DGifOpenFileHandle(fd);
+#endif
 
   transp = -1;
   data = NULL;