diff --git a/Geo/GFaceCompound.h b/Geo/GFaceCompound.h
index 74aef07aad073da7433d332211c2d9df4c72af7a..1e99312cfd4a720ef994af8cda5c9d47a0989d90 100644
--- a/Geo/GFaceCompound.h
+++ b/Geo/GFaceCompound.h
@@ -11,7 +11,7 @@
 #include "GmshConfig.h"
 #include "GmshMessage.h"
 #include "GFace.h"
-#include "simpleFunction.h"
+template <class scalar> class simpleFunction;
 
 #if defined(HAVE_SOLVER)
 
diff --git a/Mesh/BackgroundMesh.h b/Mesh/BackgroundMesh.h
index aab9c7f52198685af0745d43b45fff06a56c2135..a8981b80b8a0bd0c18ec49a8cae1d3e12769677a 100644
--- a/Mesh/BackgroundMesh.h
+++ b/Mesh/BackgroundMesh.h
@@ -7,9 +7,9 @@
 #define _BACKGROUND_MESH_H_
 
 #include "STensor3.h"
-#include "simpleFunction.h"
 #include <vector>
 #include <list>
+#include "simpleFunction.h"
 
 class MElementOctree;
 class GFace;
diff --git a/Mesh/meshMetric.h b/Mesh/meshMetric.h
index fa228ab5515dc5e29a4c3a097e123a94c86f4ba4..240ad8d9833d599cdbfdc234692dc85ba3a2e323 100644
--- a/Mesh/meshMetric.h
+++ b/Mesh/meshMetric.h
@@ -4,7 +4,7 @@
 #include "STensor3.h"
 #include "Field.h"
 #include "meshGFaceOptimize.h"
-#include "simpleFunction.h"
+template <class scalar> class simpleFunction;
 class MVertex;
 class gLevelset;
 
diff --git a/Plugin/Distance.cpp b/Plugin/Distance.cpp
index 265c914776dd74fa9b2b6a16018ff8c21b4a2654..48761bc744a61bf76ce8e1bc31fef88fb13a8be4 100644
--- a/Plugin/Distance.cpp
+++ b/Plugin/Distance.cpp
@@ -8,7 +8,6 @@
 #include "GmshConfig.h"
 #include "GModel.h"
 #include "Distance.h"
-#include "simpleFunction.h"
 #include "distanceTerm.h"
 #include "Context.h"
 #include "Numeric.h"
@@ -20,6 +19,8 @@
 #include "laplaceTerm.h"
 #include "crossConfTerm.h"
 
+template <class scalar> class simpleFunction;
+
 StringXNumber DistanceOptions_Number[] = {
   {GMSH_FULLRC, "PhysPoint", NULL, 0.},
   {GMSH_FULLRC, "PhysLine", NULL, 0.},
diff --git a/Solver/FuncGradDisc.h b/Solver/FuncGradDisc.h
index 2b5b8c7e090402ab36aea485b60a7aa0e531ed05..0dc7006ce9ce27cab8443d258f1e2fe0e9c7d043 100644
--- a/Solver/FuncGradDisc.h
+++ b/Solver/FuncGradDisc.h
@@ -11,11 +11,11 @@
 #ifndef _FUNCGRADDISC_H_
 #define _FUNCGRADDISC_H_
 
-#include "simpleFunction.h"
 #include "gmshLevelset.h"
 #include "MVertex.h"
 #include "GModel.h"
-//#include "gLevelSetMesh.cpp"
+
+template <class scalar> class simpleFunction;
 
 
 class FuncGradDisc :  public  simpleFunctionOnElement<double> {
diff --git a/Solver/elasticitySolver.h b/Solver/elasticitySolver.h
index f555f6be78882300cb3fe8af3d6fdce1c8f35fd3..0731c4d2f9a547df3bffc8b91f0452909b90448b 100644
--- a/Solver/elasticitySolver.h
+++ b/Solver/elasticitySolver.h
@@ -10,9 +10,9 @@
 #include <string>
 #include "SVector3.h"
 #include "dofManager.h"
-#include "simpleFunction.h"
 #include "functionSpace.h"
 
+template <class scalar> class simpleFunction;
 class GModel;
 class PView;
 class groupOfElements;
diff --git a/Solver/filters.h b/Solver/filters.h
index 038aaeae7ac410510af4fd5740f5e86bd46dfb42..37ca454f47e1a6e5e25f860c409186e8f7de8632 100644
--- a/Solver/filters.h
+++ b/Solver/filters.h
@@ -11,11 +11,11 @@
 #ifndef _FILTERS_H_
 #define _FILTERS_H_
 
-#include "simpleFunction.h"
 #include "dofManager.h"
 #include "GModel.h"
 #include "groupOfElements.h"
 #include "gmshLevelset.h"
+template <class scalar> class simpleFunction;
 
 class FilterNodeEnriched
 {