diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb4bd33318661489e345673f7b8688f262d5f717..27768b09099e89db41f40a688c3691ecc3e64064 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1270,7 +1270,9 @@ endif(LINUX_JOYSTICK_H)
 if(MSVC)
   add_definitions(-D_USE_MATH_DEFINES -DNOMINMAX
                   -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
-  set(GMSH_SRC ${GMSH_SRC};Fltk/Win32Icon.rc)
+  if(HAVE_FLTK)
+    set(GMSH_SRC ${GMSH_SRC};Fltk/Win32Icon.rc)
+  endif(HAVE_FLTK)
 endif(MSVC)
 
 if(WIN32 OR CYGWIN)
diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index 73e61785d8df97f17a612048e2adc662a3363497..5de96dc9a06f82a4752238712d6c50d43315065b 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -20,7 +20,6 @@ typedef unsigned long intptr_t;
 #include "Context.h"
 #include "OpenFile.h"
 #include "CommandLine.h"
-#include "ReadImg.h"
 #include "OS.h"
 #include "StringUtils.h"
 #include "GeomMeshMatcher.h"
@@ -45,6 +44,10 @@ typedef unsigned long intptr_t;
 #include "PViewOptions.h"
 #endif
 
+#if defined(HAVE_GRAPHICS)
+#include "ReadImg.h"
+#endif
+
 #if defined(HAVE_FLTK)
 #include <FL/fl_ask.H>
 #include "FlGui.h"