diff --git a/Test.hs b/Test.hs
--- a/Test.hs
+++ b/Test.hs
@@ -55,7 +55,7 @@
 versionMajor, versionMinor, versionRevision :: Int
 versionMajor    = 3
 versionMinor    = 1
-versionRevision = 0
+versionRevision = 1
 
 giveItTime :: IO ()
 giveItTime = threadDelay 500000
diff --git a/bindings-GLFW.cabal b/bindings-GLFW.cabal
--- a/bindings-GLFW.cabal
+++ b/bindings-GLFW.cabal
@@ -1,5 +1,5 @@
 name:         bindings-GLFW
-version:      3.1.2.2
+version:      3.1.2.3
 category:     Graphics
 
 author:       Brian Lewis <brian@lorf.org>
@@ -49,6 +49,10 @@
 
 --------------------------------------------------------------------------------
 
+flag system-GLFW
+  description: Use the system-wide GLFW instead of the bundled copy.
+  default: False
+
 flag MacOSXUseChdir
   description:
     Mac OS X only. Determines whether 'init' changes the current directory of
@@ -106,92 +110,96 @@
   build-depends:
     base          < 5,
     bindings-DSL == 1.0.*,
-    template-haskell >= 2.10 && < 2.12
+    template-haskell >= 2.10 && < 2.13
 
-  include-dirs:
-    glfw/include/GLFW
-    glfw/include/
-    glfw/src
+  if flag(system-glfw)
+    pkgconfig-depends:
+      glfw3 == 3.1.*
+  else
+    include-dirs:
+      glfw/include/GLFW
+      glfw/include/
+      glfw/src
 
-  c-sources:
-    glfw/src/context.c
-    glfw/src/init.c
-    glfw/src/input.c
-    glfw/src/monitor.c
-    glfw/src/window.c
+    c-sources:
+      glfw/src/context.c
+      glfw/src/init.c
+      glfw/src/input.c
+      glfw/src/monitor.c
+      glfw/src/window.c
 
-  cc-options: -D_GLFW_USE_CONFIG_H
+    cc-options: -D_GLFW_USE_CONFIG_H
 
-  if os(linux) || os(freebsd)
-    include-dirs:
-      glfw/include/os/unix-like
-    c-sources:
-      glfw/src/xkb_unicode.c
-      glfw/src/linux_joystick.c
-      glfw/src/posix_time.c
-      glfw/src/posix_tls.c
-    if flag(X)
-      c-sources:
-        glfw/src/glx_context.c
-        glfw/src/x11_init.c
-        glfw/src/x11_monitor.c
-        glfw/src/x11_window.c
-    if flag(Wayland)
-      c-sources:
-        glfw/src/egl_context.c
-        glfw/src/wl_init.c
-        glfw/src/wl_monitor.c
-        glfw/src/wl_window.c
-    if flag(Mir)
+    if os(linux) || os(freebsd)
+      include-dirs:
+        glfw/include/os/unix-like
       c-sources:
-        glfw/src/egl_context.c
-        glfw/src/mir_init.c
-        glfw/src/mir_monitor.c
-        glfw/src/mir_window.c
+        glfw/src/xkb_unicode.c
+        glfw/src/linux_joystick.c
+        glfw/src/posix_time.c
+        glfw/src/posix_tls.c
+      if flag(X)
+        c-sources:
+          glfw/src/glx_context.c
+          glfw/src/x11_init.c
+          glfw/src/x11_monitor.c
+          glfw/src/x11_window.c
+      if flag(Wayland)
+        c-sources:
+          glfw/src/egl_context.c
+          glfw/src/wl_init.c
+          glfw/src/wl_monitor.c
+          glfw/src/wl_window.c
+      if flag(Mir)
+        c-sources:
+          glfw/src/egl_context.c
+          glfw/src/mir_init.c
+          glfw/src/mir_monitor.c
+          glfw/src/mir_window.c
 
-    extra-libraries:
-      GL
-      X11
-      Xi
-      Xrandr
-      Xxf86vm
-      Xcursor
-      Xinerama
-      pthread
+      extra-libraries:
+        GL
+        X11
+        Xi
+        Xrandr
+        Xxf86vm
+        Xcursor
+        Xinerama
+        pthread
 
-  if os(darwin)
-    include-dirs:
-       glfw/include/os/darwin
-    c-sources:
-       glfw/src/mach_time.c
-       glfw/src/posix_tls.c
-       glfw/src/cocoa_init.m
-       glfw/src/iokit_joystick.m
-       glfw/src/cocoa_monitor.m
-       glfw/src/cocoa_window.m
-       glfw/src/nsgl_context.m
-    if !flag(MacOSXUseChdir)
-      cc-options: -UGLFW_USE_CHDIR
-    if !flag(MacOSXUseMenubar)
-      cc-options: -UGLFW_USE_MENUBAR
-    if !flag(MacOSXUseRetina)
-      cc-options: -UGLFW_USE_RETINA
-    frameworks: AGL Cocoa OpenGL IOKit CoreFoundation CoreVideo
+    if os(darwin)
+      include-dirs:
+         glfw/include/os/darwin
+      c-sources:
+         glfw/src/mach_time.c
+         glfw/src/posix_tls.c
+         glfw/src/cocoa_init.m
+         glfw/src/iokit_joystick.m
+         glfw/src/cocoa_monitor.m
+         glfw/src/cocoa_window.m
+         glfw/src/nsgl_context.m
+      if !flag(MacOSXUseChdir)
+        cc-options: -UGLFW_USE_CHDIR
+      if !flag(MacOSXUseMenubar)
+        cc-options: -UGLFW_USE_MENUBAR
+      if !flag(MacOSXUseRetina)
+        cc-options: -UGLFW_USE_RETINA
+      frameworks: AGL Cocoa OpenGL IOKit CoreFoundation CoreVideo
 
-  if os(mingw32)
-    include-dirs:
-      glfw/include/os/windows
-    c-sources:
-      glfw/src/win32_init.c
-      glfw/src/winmm_joystick.c
-      glfw/src/win32_monitor.c
-      glfw/src/win32_time.c
-      glfw/src/win32_window.c
-      glfw/src/win32_tls.c
-      glfw/src/wgl_context.c
-    extra-libraries:
-      opengl32
-      Gdi32
+    if os(mingw32)
+      include-dirs:
+        glfw/include/os/windows
+      c-sources:
+        glfw/src/win32_init.c
+        glfw/src/winmm_joystick.c
+        glfw/src/win32_monitor.c
+        glfw/src/win32_time.c
+        glfw/src/win32_window.c
+        glfw/src/win32_tls.c
+        glfw/src/wgl_context.c
+      extra-libraries:
+        opengl32
+        Gdi32
 
   if flag(ExposeNative)
     cc-options: -DExposeNative
@@ -213,7 +221,7 @@
 
   build-depends:
     bindings-GLFW,
-    HUnit                == 1.3.*,
+    HUnit                >= 1.3 && <1.7,
     base                  < 5,
     test-framework       == 0.8.*,
     test-framework-hunit == 0.3.*
diff --git a/glfw/src/monitor.c b/glfw/src/monitor.c
--- a/glfw/src/monitor.c
+++ b/glfw/src/monitor.c
@@ -32,6 +32,10 @@
 #include <stdlib.h>
 #include <limits.h>
 
+#if defined(_MSC_VER) || _WIN64
+#include <malloc.h>
+#define strdup _strdup
+#endif
 
 // Lexical comparison function for GLFW video modes, used by qsort
 //
