diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index e982e554fa..c0a83d4177 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -29,7 +29,7 @@
 #include <cstdlib>
 
 
-#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__)
+#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) && defined(__GNU_LIBRARY__)
 #  include <execinfo.h>
 #  include <cxxabi.h>
 #  define ICE_STACK_TRACES
@@ -252,8 +252,10 @@ getStackTrace()
     const size_t maxDepth = 100;
     void *stackAddrs[maxDepth];
 
+    #if defined(__GNU_LIBRARY__)
     size_t stackDepth = backtrace(stackAddrs, maxDepth);
     char **stackStrings = backtrace_symbols(stackAddrs, stackDepth);
+    #endif
 
     //
     // Start at 1 to skip the top frame (== call to this function)
