diff --git a/Mesh/Levy3D.cpp b/Mesh/Levy3D.cpp
index 5231b135b691ea5ec27d0ad12b9587a594533c05..7cb987009df47ff266a01ef3ae2afecffbad1e98 100755
--- a/Mesh/Levy3D.cpp
+++ b/Mesh/Levy3D.cpp
@@ -1,3 +1,7 @@
+#include "GmshConfig.h"
+
+#if defined(HAVE_BFGS)
+
 #include "Levy3D.h"
 #include "polynomialBasis.h"
 #include "Gauss.h"
@@ -1107,3 +1111,5 @@ void call_back(const alglib::real_1d_array& x,double& func,alglib::real_1d_array
   grad[0] = -2.0*(3.0-x[0]);
   grad[1] = -2.0*(4.0-x[1]);
 }
+
+#endif