diff --git a/contrib/Netgen/libsrc/general/profiler.cpp b/contrib/Netgen/libsrc/general/profiler.cpp
index 91db4effd364eb821e6865d75b49cfe3be61118d..e3f85e9e09a88333df497a1b13beb4b8d353460f 100644
--- a/contrib/Netgen/libsrc/general/profiler.cpp
+++ b/contrib/Netgen/libsrc/general/profiler.cpp
@@ -6,6 +6,7 @@
 
 
 #include <myadt.hpp>
+#include <cstdlib>
 
 namespace netgen
 {
@@ -28,6 +29,7 @@ namespace netgen
 
     total_timer = CreateTimer ("total CPU time");
     StartTimer (total_timer);
+    envNGPROFILE = getenv ("NGPROFILE");
   }
 
   NgProfiler :: ~NgProfiler()
@@ -43,7 +45,7 @@ namespace netgen
     // which leads to an "order of destruction"-problem,
     // thus we use the C-variant:
 
-    if (getenv ("NGPROFILE"))
+    if (envNGPROFILE)
       {
 	char filename[100];
 #ifdef PARALLEL
diff --git a/contrib/Netgen/libsrc/general/profiler.hpp b/contrib/Netgen/libsrc/general/profiler.hpp
index a3ad811c5af49648ad2cf1a92316efc290c65472..27e028eb44de8d5e0b0e7e412658a7f9bdd7771a 100644
--- a/contrib/Netgen/libsrc/general/profiler.hpp
+++ b/contrib/Netgen/libsrc/general/profiler.hpp
@@ -30,7 +30,9 @@ class NgProfiler
   static string names[SIZE];
   static int usedcounter[SIZE];
 
+  bool envNGPROFILE;
   int total_timer;
+  
 public: 
   NgProfiler();
   ~NgProfiler();