diff -ur mongo-cxx-driver-v2.2_vs/SConstruct mongo-cxx-driver-v2.2/SConstruct
--- mongo-cxx-driver-v2.2_vs/SConstruct	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/SConstruct	2012-10-09 22:37:22 +0400
@@ -21,13 +21,12 @@
           default="/usr/local",
           help="installation root")
 
-
 env = Environment(BUILD_DIR='#build',
                   CLIENT_ARCHIVE='${CLIENT_DIST_BASENAME}${DIST_ARCHIVE_SUFFIX}',
                   CLIENT_DIST_BASENAME='mongo-cxx-driver',
                   CLIENT_LICENSE='#LICENSE.txt',
                   CLIENT_SCONSTRUCT='#SConstruct',
-                  MSVS_ARCH=None,
+				  TOOLS=['mingw'],
                   PYTHON=sys.executable)
 
 def addExtraLibs(s):
@@ -41,6 +40,11 @@
 
 env.Prepend(CPPPATH=["$BUILD_DIR", "$BUILD_DIR/mongo"])
 env.Append(CPPDEFINES=[ "_SCONS", "MONGO_EXPOSE_MACROS" ])
+env.Append(CPPDEFINES=[ "_SCONS", "BOOST_THREAD_USE_LIB" ])
+
+MONGO_BOOST_TIME_UTC_HACK=ARGUMENTS.get('MONGO_BOOST_TIME_UTC_HACK',0)
+if (MONGO_BOOST_TIME_UTC_HACK):
+    env.Append(CPPDEFINES=[ "_SCONS", "MONGO_BOOST_TIME_UTC_HACK" ]) #for boost>=1.5
 
 nix = False
 linux = False
@@ -57,7 +61,17 @@
 
 if win:
     env['DIST_ARCHIVE_SUFFIX'] = '.zip'
-    env.Append(CCFLAGS=['/EHsc', '/O2'])
+    boost_path=ARGUMENTS.get('boost_path',None) #boost_path="C:/MinGW/msys/1.0/home/den/boost/" 
+    gcc_path=ARGUMENTS.get('gcc_path',None) #gcc_path="D:/MinGW/bin" 
+    if (boost_path):
+	    env.Append(CPPPATH = [os.path.join(boost_path, "include")])
+	    env.Append(LIBPATH = [os.path.join(boost_path, "lib")])
+    if (gcc_path):
+		env.Replace(AR = [os.path.join(gcc_path, "ar")])
+		env.Replace(AS = [os.path.join(gcc_path, "as")])
+		env.Replace(CXX = [os.path.join(gcc_path, "g++")])
+		env.Replace(RANLIB = [os.path.join(gcc_path, "ranlib")])
+        #env.Replace(CPPPATH = "D:/Mingw/bin")
 else:
     env['DIST_ARCHIVE_SUFFIX'] = '.tgz'
 
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/bson/util/builder.h mongo-cxx-driver-v2.2/src/mongo/bson/util/builder.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/bson/util/builder.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/bson/util/builder.h	2012-10-08 19:12:13 +0400
@@ -249,7 +249,11 @@
 
     namespace {
 #if defined(_WIN32)
-        int (*mongo_snprintf)(char *str, size_t size, const char *format, ...) = &sprintf_s;
+	#if defined(__MINGW32__)
+		int (*mongo_snprintf)(char *str, size_t size, const char *format, ...) = &snprintf;
+	#else
+		int (*mongo_snprintf)(char *str, size_t size, const char *format, ...) = &sprintf_s;		
+	#endif	
 #else
         int (*mongo_snprintf)(char *str, size_t size, const char *format, ...) = &snprintf;
 #endif
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/bson/util/misc.h mongo-cxx-driver-v2.2/src/mongo/bson/util/misc.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/bson/util/misc.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/bson/util/misc.h	2012-10-08 19:11:22 +0400
@@ -22,14 +22,38 @@
 #include <ctime>
 #include <limits>
 #include <string>
+#include <string.h>
 
 #include "mongo/util/assert_util.h"
 
+#if defined(__MINGW32__)
+	#undef ctime_r
+	#define ctime_r(_Time,_Str)	({ char *___tmp_tm;			\
+							___tmp_tm = ctime((_Time));  \
+							if (___tmp_tm)		\
+							 ___tmp_tm =		\
+							   strcpy((_Str),___tmp_tm); \
+							___tmp_tm;	})
+
+	#undef gmtime_r
+	#define gmtime_r(_Time,_Tm)	({ struct tm *___tmp_tm;		\
+							___tmp_tm = gmtime((_Time)); \
+							if (___tmp_tm) {	\
+							  *(_Tm) = *___tmp_tm;	\
+							  ___tmp_tm = (_Tm);	\
+							}			\
+							___tmp_tm;	})
+#endif					
+
 namespace mongo {
 
     inline void time_t_to_String(time_t t, char *buf) {
 #if defined(_WIN32)
+	#if defined(__MINGW32__)
+		strncpy(buf,ctime(&t),32);
+	#else
         ctime_s(buf, 32, &t);
+	#endif	
 #else
         ctime_r(&t, buf);
 #endif
@@ -39,7 +63,11 @@
     inline std::string time_t_to_String(time_t t = time(0) ) {
         char buf[64];
 #if defined(_WIN32)
+	#if defined(__MINGW32__)
+		ctime_r(&t, buf);
+	#else
         ctime_s(buf, sizeof(buf), &t);
+	#endif	
 #else
         ctime_r(&t, buf);
 #endif
@@ -50,7 +78,11 @@
     inline std::string time_t_to_String_no_year(time_t t) {
         char buf[64];
 #if defined(_WIN32)
+	#if defined(__MINGW32__)
+		ctime_r(&t, buf);
+	#else
         ctime_s(buf, sizeof(buf), &t);
+	#endif	
 #else
         ctime_r(&t, buf);
 #endif
@@ -61,7 +93,11 @@
     inline std::string time_t_to_String_short(time_t t) {
         char buf[64];
 #if defined(_WIN32)
+	#if defined(__MINGW32__)
+		ctime_r(&t, buf);
+	#else
         ctime_s(buf, sizeof(buf), &t);
+	#endif	
 #else
         ctime_r(&t, buf);
 #endif
@@ -81,9 +117,13 @@
         void toTm (tm *buf) {
             time_t dtime = toTimeT();
 #if defined(_WIN32)
-            gmtime_s(buf, &dtime);
+	#if defined(__MINGW32__)
+		gmtime_r(&dtime, buf);
+	#else
+        gmtime_s(buf, &dtime);
+	#endif	
 #else
-            gmtime_r(&dtime, buf);
+		gmtime_r(&dtime, buf);
 #endif
         }
         std::string toString() const {
Only in mongo-cxx-driver-v2.2/src/mongo/client/examples: main.cpp
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/db/nonce.cpp mongo-cxx-driver-v2.2/src/mongo/db/nonce.cpp
--- mongo-cxx-driver-v2.2_vs/src/mongo/db/nonce.cpp	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/db/nonce.cpp	2012-10-08 20:17:18 +0400
@@ -61,10 +61,14 @@
         _devrandom->read((char*)&n, sizeof(n));
         massert(10355 , "devrandom failed", !_devrandom->fail());
 #elif defined(_WIN32)
+	#if defined(__MINGW32__)
+		n=(((unsigned long long)(((unsigned int)rand())<<16|rand()))<<32) | (((unsigned int)rand())<<16|rand());
+	#else
         unsigned a=0, b=0;
         verify( rand_s(&a) == 0 );
         verify( rand_s(&b) == 0 );
         n = (((unsigned long long)a)<<32) | b;
+	#endif	
 #else
         n = (((unsigned long long)random())<<32) | random();
 #endif
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/pch.h mongo-cxx-driver-v2.2/src/mongo/pch.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/pch.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/pch.h	2012-10-09 15:07:39 +0400
@@ -44,7 +44,13 @@
 #include "string.h"
 #include "limits.h"
 
+#include <boost/version.hpp>
+#if BOOST_VERSION >= 105000
+#define BOOST_FILESYSTEM_VERSION 3
+#else
 #define BOOST_FILESYSTEM_VERSION 2
+#endif
+
 #include <boost/shared_ptr.hpp>
 #include <boost/smart_ptr.hpp>
 #include <boost/function.hpp>
Only in mongo-cxx-driver-v2.2/src/mongo/platform: __atomic_intrinsics_win32.h
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/platform/atomic_intrinsics_win32.h mongo-cxx-driver-v2.2/src/mongo/platform/atomic_intrinsics_win32.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/platform/atomic_intrinsics_win32.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/platform/atomic_intrinsics_win32.h	2012-08-13 21:38:00 +0400
@@ -14,7 +14,8 @@
  */
 
 /**
- * Implementation of the AtomicIntrinsics<T>::* operations for Windows systems.
+ * Implementation of the AtomicIntrinsics<T>::* operations for IA-32 and AMD64 systems using a
+ * GCC-compatible compiler toolchain.
  */
 
 #pragma once
@@ -24,47 +25,61 @@
 namespace mongo {
 
     /**
-     * Default instantiation of AtomicIntrinsics<>, for unsupported types.
+     * Instantiation of AtomicIntrinsics<> for all word types T where sizeof<T> <= sizeof(void *).
+     *
+     * On 32-bit systems, this handles 8-, 16- and 32-bit word types.  On 64-bit systems,
+     * it handles 8-, 16, 32- and 64-bit types.
      */
-    template <typename T, typename _IsTSupported=void>
+    template <typename T, typename IsTLarge=void>
     class AtomicIntrinsics {
-    private:
-        AtomicIntrinsics();
-        ~AtomicIntrinsics();
-    };
-
-    /**
-     * Instantiation of AtomicIntrinsics<> for 32-bit word sizes (i.e., unsigned).
-     */
-    template <typename T>
-    class AtomicIntrinsics<T, typename boost::enable_if_c<sizeof(T) == sizeof(LONG)>::type> {
     public:
 
         static T compareAndSwap(volatile T* dest, T expected, T newValue) {
-            return InterlockedCompareExchange(reinterpret_cast<volatile LONG*>(dest),
-                                              LONG(newValue),
-                                              LONG(expected));
+
+            T result;
+            asm volatile ("lock cmpxchg %[src], %[dest]"
+                          : [dest] "+m" (*dest),
+                            "=a" (result)
+                          : [src] "r" (newValue),
+                            "a" (expected)
+                          : "memory", "cc");
+            return result;
         }
 
         static T swap(volatile T* dest, T newValue) {
-            return InterlockedExchange(reinterpret_cast<volatile LONG*>(dest), LONG(newValue));
+
+            T result = newValue;
+            // No need for "lock" prefix on "xchg".
+            asm volatile ("xchg %[r], %[dest]"
+                          : [dest] "+m" (*dest),
+                            [r] "+r" (result)
+                          :
+                          : "memory");
+            return result;
         }
 
         static T load(volatile const T* value) {
-            MemoryBarrier();
+            asm volatile ("mfence" ::: "memory");
             T result = *value;
-            MemoryBarrier();
+            asm volatile ("mfence" ::: "memory");
             return result;
         }
 
         static void store(volatile T* dest, T newValue) {
-            MemoryBarrier();
+            asm volatile ("mfence" ::: "memory");
             *dest = newValue;
-            MemoryBarrier();
+            asm volatile ("mfence" ::: "memory");
         }
 
         static T fetchAndAdd(volatile T* dest, T increment) {
-            return InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(dest), LONG(increment));
+
+            T result = increment;
+            asm volatile ("lock xadd %[src], %[dest]"
+                          : [dest] "+m" (*dest),
+                            [src] "+r" (result)
+                          :
+                          : "memory", "cc");
+            return result;
         }
 
     private:
@@ -73,80 +88,75 @@
     };
 
     /**
-     * Instantiation of AtomicIntrinsics<> for 64-bit word sizes.
+     * Instantiation of AtomicIntrinsics<T> where sizeof<T> exceeds sizeof(void*).
+     *
+     * On 32-bit systems, this handles the 64-bit word type.  Not used on 64-bit systems.
+     *
+     * Note that the implementations of swap, store and fetchAndAdd spin until they succeed.  This
+     * implementation is thread-safe, but may have poor performance in high-contention environments.
+     * However, no superior solution exists for IA-32 (32-bit x86) systems.
      */
     template <typename T>
-    class AtomicIntrinsics<T, typename boost::enable_if_c<sizeof(T) == sizeof(LONGLONG)>::type> {
+    class AtomicIntrinsics<T, typename boost::disable_if_c<sizeof(T) <= sizeof(void*)>::type> {
     public:
-
         static T compareAndSwap(volatile T* dest, T expected, T newValue) {
-            return InterlockedCompareExchange64(reinterpret_cast<volatile LONGLONG*>(dest),
-                                                LONGLONG(newValue),
-                                                LONGLONG(expected));
+            T result = expected;
+            asm volatile ("push %%eax\n"
+                          "push %%ebx\n"
+                          "push %%ecx\n"
+                          "push %%edx\n"
+                          "mov (%%edx), %%ebx\n"
+                          "mov 4(%%edx), %%ecx\n"
+                          "mov (%%edi), %%eax\n"
+                          "mov 4(%%edi), %%edx\n"
+                          "lock cmpxchg8b (%%esi)\n"
+                          "mov %%eax, (%%edi)\n"
+                          "mov %%edx, 4(%%edi)\n"
+                          "pop %%edx\n"
+                          "pop %%ecx\n"
+                          "pop %%ebx\n"
+                          "pop %%eax\n"
+                          :
+                          : "S" (dest),
+                            "D" (&result),
+                            "d" (&newValue)
+                          : "memory", "cc");
+            return result;
         }
 
         static T swap(volatile T* dest, T newValue) {
-            return InterlockedExchange64(reinterpret_cast<volatile LONGLONG*>(dest),
-                                         LONGLONG(newValue));
+
+        T expected;
+        T actual;
+            do {
+                expected = *dest;
+                actual = compareAndSwap(dest, expected, newValue);
+            } while (actual != expected);
+            return actual;
         }
 
         static T load(volatile const T* value) {
-            return LoadStoreImpl<T>::load(value);
+            return compareAndSwap(const_cast<volatile T*>(value), T(0), T(0));
         }
 
         static void store(volatile T* dest, T newValue) {
-            LoadStoreImpl<T>::store(dest, newValue);
+            swap(dest, newValue);
         }
 
         static T fetchAndAdd(volatile T* dest, T increment) {
-            return InterlockedExchangeAdd64(reinterpret_cast<volatile LONGLONG*>(dest),
-                                            LONGLONG(increment));
+
+            T expected;
+            T actual;
+            do {
+                expected = load(dest);
+                actual = compareAndSwap(dest, expected, expected + increment);
+            } while (actual != expected);
+            return actual;
         }
 
     private:
         AtomicIntrinsics();
         ~AtomicIntrinsics();
-
-        // On 32-bit IA-32 systems, 64-bit load and store must be implemented in terms of
-        // Interlocked operations, but on 64-bit systems they support a simpler, native
-        // implementation.  The LoadStoreImpl type represents the abstract implementation of
-        // loading and storing 64-bit values.
-        template <typename T, typename _IsTTooBig=void>
-        class LoadStoreImpl{};
-
-        // Implementation on 64-bit systems.
-        template <typename U>
-        class LoadStoreImpl<U, typename boost::enable_if_c<sizeof(U) <= sizeof(void*)>::type> {
-        public:
-            static U load(volatile const U* value) {
-                MemoryBarrier();
-                U result = *value;
-                MemoryBarrier();
-                return result;
-            }
-
-
-            static void store(volatile U* dest, U newValue) {
-                MemoryBarrier();
-                *dest = newValue;
-                MemoryBarrier();
-            }
-        };
-
-        // Implementation on 32-bit systems.
-        template <typename U>
-        class LoadStoreImpl<U, typename boost::disable_if_c<sizeof(U) <= sizeof(void*)>::type> {
-        public:
-            static U load(volatile const U* value) {
-                return AtomicIntrinsics<U>::compareAndSwap(const_cast<volatile U*>(value),
-                                                           U(0),
-                                                           U(0));
-            }
-
-            static void store(volatile U* dest, U newValue) {
-                AtomicIntrinsics<U>::swap(dest, newValue);
-            }
-        };
     };
 
 }  // namespace mongo
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/platform/windows_basic.h mongo-cxx-driver-v2.2/src/mongo/platform/windows_basic.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/platform/windows_basic.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/platform/windows_basic.h	2012-10-08 18:21:18 +0400
@@ -13,6 +13,7 @@
 # include "mongo/targetver.h"
 # include <winsock2.h> //this must be included before the first windows.h include
 # include <ws2tcpip.h>
-# include <wspiapi.h>
+//# include <wspiapi.h>
+# include <ws2spi.h>
 # include <windows.h>
 #endif
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/concurrency/spin_lock.h mongo-cxx-driver-v2.2/src/mongo/util/concurrency/spin_lock.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/concurrency/spin_lock.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/concurrency/spin_lock.h	2012-10-09 18:11:07 +0400
@@ -41,7 +41,16 @@
 #if defined(_WIN32)
         CRITICAL_SECTION _cs;
     public:
-        void lock() {EnterCriticalSection(&_cs); }
+		#if defined(__MINGW32__) 
+			#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
+				volatile bool _locked;
+				void lock();
+			#else
+				void lock() {EnterCriticalSection(&_cs); }
+			#endif
+		#else
+		void lock() {EnterCriticalSection(&_cs); }
+		#endif
         void unlock() { LeaveCriticalSection(&_cs); }
 #elif defined(__USE_XOPEN2K)
         pthread_spinlock_t _lock;
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/net/sock.h mongo-cxx-driver-v2.2/src/mongo/util/net/sock.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/net/sock.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/net/sock.h	2012-10-08 21:41:18 +0400
@@ -39,6 +39,10 @@
 #include <openssl/ssl.h>
 #endif
 
+#if defined(__MINGW32__)
+	#define IPV6_V6ONLY  26
+#endif	
+
 namespace mongo {
 
     const int SOCK_FAMILY_UNKNOWN_ERROR=13078;
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/stacktrace.cpp mongo-cxx-driver-v2.2/src/mongo/util/stacktrace.cpp
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/stacktrace.cpp	2012-08-22 19:43:45 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/stacktrace.cpp	2012-10-09 18:24:29 +0400
@@ -13,7 +13,7 @@
 #include <stdio.h>
 #include <boost/smart_ptr/scoped_array.hpp>
 #include "mongo/platform/windows_basic.h"
-#include <DbgHelp.h>
+//#include <DbgHelp.h>
 #include "mongo/util/assert_util.h"
 #include "mongo/util/log.h"
 #endif
@@ -51,6 +51,12 @@
 
 #elif defined(_WIN32)
 
+#if defined(__MINGW32__)
+namespace mongo {
+	void printWindowsStackTrace(CONTEXT &context, std::ostream &os) {}
+	void printStackTrace( std::ostream& os ){}
+}
+#else
 namespace mongo {
 
     /**
@@ -265,7 +271,7 @@
         }
     }
 }
-
+#endif
 #else
 
 namespace mongo {
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/stacktrace.h mongo-cxx-driver-v2.2/src/mongo/util/stacktrace.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/stacktrace.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/stacktrace.h	2012-10-08 21:11:47 +0400
@@ -16,8 +16,12 @@
     void printStackTrace(std::ostream &os=std::cout);
 
 #if defined(_WIN32)
-    // Print stack trace (using a specified stack context) to "os", default to std::cout.
-    void printWindowsStackTrace(CONTEXT &context, std::ostream &os=std::cout);
+	#if defined(__MINGW32__)
+		void printWindowsStackTrace(CONTEXT &context, std::ostream &os=std::cout);
+	#else
+		// Print stack trace (using a specified stack context) to "os", default to std::cout.
+		void printWindowsStackTrace(CONTEXT &context, std::ostream &os=std::cout);
+	#endif
 #endif
 
 }  // namespace mongo
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/text.cpp mongo-cxx-driver-v2.2/src/mongo/util/text.cpp
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/text.cpp	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/text.cpp	2012-10-08 22:15:50 +0400
@@ -144,9 +144,15 @@
         }
         uassert( 13306, "could not convert string to long long", endLen != 0 && n[ endLen ] == 0 );
 #else // stoll() wasn't introduced until VS 2010.
-        char* endPtr = 0;
-        ret = _strtoi64( n, &endPtr, 10 );
-        uassert( 13310, "could not convert string to long long", (*endPtr == 0) && (ret != _I64_MAX) && (ret != _I64_MIN) );
+		#if defined(__MINGW32__)
+			char *endPtr = 0;
+			ret = strtoll( n, &endPtr, 10 );
+			uassert( 13310, "could not convert string to long long", (*endPtr == 0) && (ret != _I64_MAX) && (ret != _I64_MIN) );
+		#else
+			char* endPtr = 0;
+			ret = _strtoi64( n, &endPtr, 10 );
+			uassert( 13310, "could not convert string to long long", (*endPtr == 0) && (ret != _I64_MAX) && (ret != _I64_MIN) );
+		#endif	
 #endif // !defined(_WIN32)
         return ret;
     }
@@ -287,7 +293,11 @@
         _argv = reinterpret_cast< char** >( malloc( blockSize ) );
         for ( int i = 0; i < argc; ++i ) {
             _argv[ i ] = reinterpret_cast< char * >( _argv ) + blockPtr;
-            strcpy_s( _argv[ i ], utf8argLength[ i ], utf8args[ i ].c_str() );
+			#if defined(__MINGW32__)
+				strncpy( _argv[ i ], utf8args[ i ].c_str(),utf8argLength[ i ] );
+			#else
+				strcpy_s( _argv[ i ], utf8argLength[ i ], utf8args[ i ].c_str() );			
+			#endif	
             blockPtr += utf8argLength[ i ];
         }
     }
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/text.h mongo-cxx-driver-v2.2/src/mongo/util/text.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/text.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/text.h	2012-10-08 22:12:29 +0400
@@ -85,8 +85,8 @@
     bool writeUtf8ToWindowsConsole( const char* utf8String, unsigned int utf8StringSize );
 
     /* like toWideString but UNICODE macro sensitive */
-# if !defined(_UNICODE)
-#error temp error 
+#if !defined(_UNICODE)
+//#error temp error 
     inline std::string toNativeString(const char *s) { return s; }
 # else
     inline std::wstring toNativeString(const char *s) { return toWideString(s); }
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/time_support.cpp mongo-cxx-driver-v2.2/src/mongo/util/time_support.cpp
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/time_support.cpp	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/time_support.cpp	2012-10-08 22:31:23 +0400
@@ -26,6 +26,25 @@
 
 #include "mongo/util/assert_util.h"
 
+#if defined(__MINGW32__)
+#undef localtime_r
+#define localtime_r(_Time, _Tm)	({ struct tm *___tmp_tm;		\
+						___tmp_tm = localtime((_Time));\
+						if (___tmp_tm) {	\
+						  *(_Tm) = *___tmp_tm;	\
+						  ___tmp_tm = (_Tm);	\
+						}			\
+						___tmp_tm;	})
+						
+#undef gmtime_r
+#define gmtime_r(_Time,_Tm)	({ struct tm *___tmp_tm;		\
+						___tmp_tm = gmtime((_Time)); \
+						if (___tmp_tm) {	\
+						  *(_Tm) = *___tmp_tm;	\
+						  ___tmp_tm = (_Tm);	\
+						}			\
+						___tmp_tm;	})
+#endif						
 
 namespace mongo {
 
@@ -38,9 +57,17 @@
     void time_t_to_Struct(time_t t, struct tm * buf , bool local) {
 #if defined(_WIN32)
         if ( local )
-            localtime_s( buf , &t );
+			#if defined(__MINGW32__)
+				localtime_r(&t, buf);
+			#else
+				localtime_s( buf , &t );
+			#endif		
         else
-            gmtime_s(buf, &t);
+			#if defined(__MINGW32__)
+				gmtime_r(&t, buf);				
+			#else
+				gmtime_s(buf, &t);
+			#endif	
 #else
         if ( local )
             localtime_r(&t, buf);
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/time_support.h mongo-cxx-driver-v2.2/src/mongo/util/time_support.h
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/time_support.h	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/time_support.h	2012-10-09 21:43:50 +0400
@@ -81,10 +81,10 @@
     unsigned long long curTimeMillis64();
 
     // these are so that if you use one of them compilation will fail
-    char *asctime(const struct tm *tm);
+    /*char *asctime(const struct tm *tm);
     char *ctime(const time_t *timep);
     struct tm *gmtime(const time_t *timep);
-    struct tm *localtime(const time_t *timep);
+    struct tm *localtime(const time_t *timep);*/
 
 #if defined(MONGO_BOOST_TIME_UTC_HACK) || (BOOST_VERSION >= 105000)
 #define MONGO_BOOST_TIME_UTC boost::TIME_UTC_
diff -ur mongo-cxx-driver-v2.2_vs/src/mongo/util/util.cpp mongo-cxx-driver-v2.2/src/mongo/util/util.cpp
--- mongo-cxx-driver-v2.2_vs/src/mongo/util/util.cpp	2012-08-13 21:38:00 +0400
+++ mongo-cxx-driver-v2.2/src/mongo/util/util.cpp	2012-10-09 13:56:41 +0400
@@ -65,11 +65,13 @@
         info.szName = name;
         info.dwThreadID = -1;
         info.dwFlags = 0;
-        __try {
-            RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
-        }
-        __except(EXCEPTION_EXECUTE_HANDLER) {
-        }
+		#if !defined(__MINGW32__)
+		__try {
+			RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
+		}
+		__except(EXCEPTION_EXECUTE_HANDLER) {
+		}
+		#endif	
     }
 #endif
 
