diff --git a/configure.in b/configure.in
index 481ce4ca719eb186ec06d44f63a40c5c3a4bfd37..dd749fae82910069dc1c09ea646bfe3951f46c2f 100644
--- a/configure.in
+++ b/configure.in
@@ -378,7 +378,7 @@ then
   # mysqld doesn't use run-time-type-checking, so we disable it.
   CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
   # ndb cannot be compiled with -fno-implicit-templaces
-  ndb_cxxflags_fix=-fimplicit-templates
+  ndb_cxxflags_fix="$ndb_cxxflags_fix -fimplicit-templates"
 
   # If you are using 'gcc' 3.0 (not g++) to compile C++ programs on Linux,
   # we will gets some problems when linking static programs.
@@ -1032,6 +1032,7 @@ case $SYSTEM_TYPE in
       CXXFLAGS="$CXXFLAGS +O2"
       MAX_C_OPTIMIZE=""
       MAX_CXX_OPTIMIZE=""
+      ndb_cxxflags_fix="$ndb_cxxflags_fix -Aa"
     fi
     ;;
   *rhapsody*)
diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h
index bd1e4954f14ad1d03b560a06c2796ebe42465121..f871acbc0753d52c371f9e3c529b481766adfe7a 100644
--- a/ndb/include/ndb_global.h
+++ b/ndb/include/ndb_global.h
@@ -25,7 +25,13 @@
 #endif
 #include <sys/param.h>
 #ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
+  #if defined(__cplusplus) && defined(_APP32_64BIT_OFF_T) && defined(_INCLUDE_AES_SOURCE)
+    #undef _INCLUDE_AES_SOURCE
+    #include <sys/stat.h>
+    #define _INCLUDE_AES_SOURCE
+  #else
+    #include <sys/stat.h>
+  #endif
 #endif
 #include <sys/resource.h>
 #ifdef HAVE_SYS_WAIT_H