diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp
index c8cba8e3f2b284f71bcbb89d264b0cc00f194056..60f35d61b5982852d0005fdf9994bae2b644d31f 100644
--- a/Fltk/Main.cpp
+++ b/Fltk/Main.cpp
@@ -11,7 +11,7 @@
 #include "Options.h"
 #include "PluginManager.h"
 #include "GModel.h"
-#if defined(__linux__) && !defined(BUILD_ANDROID)
+#if defined(HAVE_ONELAB2) && defined(__linux__) && !defined(BUILD_ANDROID)
 #include <X11/Xlib.h>
 #endif
 
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
   }
 
   // Interactive Gmsh with FLTK GUI
-#if defined(__linux__) && !defined(BUILD_ANDROID)
+#if defined(HAVE_ONELAB2) && defined(__linux__) && !defined(BUILD_ANDROID)
   XInitThreads();
 #endif
   return GmshFLTK(argc, argv);