diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index f860a2cf2bc6f2f8494308320361f9430731c405..4c37dedfb90fcc44d947f9949aef7c5d7b4267a7 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -72,6 +72,16 @@ GModel *GModel::current(int index)
   return list[_current];
 }
 
+int GModel::setCurrent(GModel *m)
+{
+  for (unsigned int i = 0; i < list.size(); i++){
+    if (list[i] == m){
+      _current = i;
+      return i;
+    }
+  }
+}
+
 GModel *GModel::findByName(std::string name)
 {
   // return last mesh with given name
diff --git a/Geo/GModel.h b/Geo/GModel.h
index 719d9b6245ae8b300ea08ebb389fb8d5c405d61f..be75c7eb3c96e627187e6839c7a0e2974bef043a 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -122,16 +122,7 @@ class GModel
   static GModel *current(int index=-1);
   
   // sets a model to current
-  static int setCurrent(GModel *m){
-    for (int i=0;i<list.size();i++){
-      if (list[i] ==m){
-	_current = i;
-	return i;
-      }
-    }
-  }
-  
-
+  static int setCurrent(GModel *m);
 
   // find a model by name
   static GModel *findByName(std::string name);
diff --git a/Geo/LuaBindings_Geo.cpp b/Geo/LuaBindings_Geo.cpp
index a9cd89477dd7211be48c338955579094f57956f9..f237b3d0cdef5017b3e4450f72c5d4ffa1eaacc7 100644
--- a/Geo/LuaBindings_Geo.cpp
+++ b/Geo/LuaBindings_Geo.cpp
@@ -1,6 +1,9 @@
 #include "LuaBindings_Geo.h"
 #include "OpenFile.h"
 #include "CreateFile.h"
+
+#if defined(HAVE_LUA)
+
 // define the name of the object that will be used
 // in Lua
 
@@ -49,3 +52,5 @@ int LuaGModel::save(lua_State *L){
   GModel::setCurrent(temp);
   return 1;
 }
+
+#endif