Index: library/tests/loggers_test.cpp
===================================================================
--- library/tests/loggers_test.cpp (revision 425)
+++ library/tests/loggers_test.cpp (revision 469)
@@ -2,4 +2,5 @@
 #include "base/loggers.h"
 #include "test_util.h"
+#include "osutils.h"
 #include "UnitTest++.h"
 #include <string>
@@ -14,7 +15,6 @@
     RV r = RV("{r }", "2");
 
-    if (mkdir("exp", 0777)) {
+    makedir(string("exp"));
 	remove_all("exp/dirfile");
-    }
 
     dirfilelog L("exp/dirfile", 10);
Index: library/tests/dirent.c
===================================================================
--- library/tests/dirent.c (revision 469)
+++ library/tests/dirent.c (revision 469)
@@ -0,0 +1,145 @@
+/*
+
+    Implementation of POSIX directory browsing functions and types for Win32.
+
+    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
+    History: Created March 1997. Updated June 2003.
+    Rights:  See end of file.
+
+*/
+
+#include "dirent.h"
+#include <errno.h>
+#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct DIR
+{
+    long                handle; /* -1 for failed rewind */
+    struct _finddata_t  info;
+    struct dirent       result; /* d_name null iff first time */
+    char                *name;  /* null-terminated char string */
+};
+
+DIR *opendir(const char *name)
+{
+    DIR *dir = 0;
+
+    if(name && name[0])
+    {
+        size_t base_length = strlen(name);
+        const char *all = /* search pattern must end with suitable wildcard */
+            strchr("/\\", name[base_length - 1]) ? "*" : "/*";
+
+        if((dir = (DIR *) malloc(sizeof *dir)) != 0 &&
+           (dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0)
+        {
+            strcat(strcpy(dir->name, name), all);
+
+            if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1)
+            {
+                dir->result.d_name = 0;
+            }
+            else /* rollback */
+            {
+                free(dir->name);
+                free(dir);
+                dir = 0;
+            }
+        }
+        else /* rollback */
+        {
+            free(dir);
+            dir   = 0;
+            errno = ENOMEM;
+        }
+    }
+    else
+    {
+        errno = EINVAL;
+    }
+
+    return dir;
+}
+
+int closedir(DIR *dir)
+{
+    int result = -1;
+
+    if(dir)
+    {
+        if(dir->handle != -1)
+        {
+            result = _findclose(dir->handle);
+        }
+
+        free(dir->name);
+        free(dir);
+    }
+
+    if(result == -1) /* map all errors to EBADF */
+    {
+        errno = EBADF;
+    }
+
+    return result;
+}
+
+struct dirent *readdir(DIR *dir)
+{
+    struct dirent *result = 0;
+
+    if(dir && dir->handle != -1)
+    {
+        if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
+        {
+            result         = &dir->result;
+            result->d_name = dir->info.name;
+        }
+    }
+    else
+    {
+        errno = EBADF;
+    }
+
+    return result;
+}
+
+void rewinddir(DIR *dir)
+{
+    if(dir && dir->handle != -1)
+    {
+        _findclose(dir->handle);
+        dir->handle = (long) _findfirst(dir->name, &dir->info);
+        dir->result.d_name = 0;
+    }
+    else
+    {
+        errno = EBADF;
+    }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+
+    Copyright Kevlin Henney, 1997, 2003. All rights reserved.
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose is hereby granted without fee, provided
+    that this copyright and permissions notice appear in all copies and
+    derivatives.
+    
+    This software is supplied "as is" without express or implied warranty.
+
+    But that said, if there are any problems please get in touch.
+
+*/
Index: library/tests/dirent.h
===================================================================
--- library/tests/dirent.h (revision 469)
+++ library/tests/dirent.h (revision 469)
@@ -0,0 +1,50 @@
+#ifndef DIRENT_INCLUDED
+#define DIRENT_INCLUDED
+
+/*
+
+    Declaration of POSIX directory browsing functions and types for Win32.
+
+    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
+    History: Created March 1997. Updated June 2003.
+    Rights:  See end of file.
+    
+*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct DIR DIR;
+
+struct dirent
+{
+    char *d_name;
+};
+
+DIR           *opendir(const char *);
+int           closedir(DIR *);
+struct dirent *readdir(DIR *);
+void          rewinddir(DIR *);
+
+/*
+
+    Copyright Kevlin Henney, 1997, 2003. All rights reserved.
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose is hereby granted without fee, provided
+    that this copyright and permissions notice appear in all copies and
+    derivatives.
+    
+    This software is supplied "as is" without express or implied warranty.
+
+    But that said, if there are any problems please get in touch.
+
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: library/tests/CMakeLists.txt
===================================================================
--- library/tests/CMakeLists.txt (revision 468)
+++ library/tests/CMakeLists.txt (revision 469)
@@ -7,12 +7,20 @@
 link_directories (./unittest-cpp)
 
-add_library(testutil egiw_harness.cpp egiw_harness.h epdf_harness.cpp epdf_harness.h mat_checks.cpp mat_checks.h mpdf_harness.cpp mpdf_harness.h square_mat_point.cpp square_mat_point.h test_util.cpp test_util.h)
+SET(testutil_src egiw_harness.cpp egiw_harness.h epdf_harness.cpp epdf_harness.h mat_checks.cpp mat_checks.h mpdf_harness.cpp mpdf_harness.h square_mat_point.cpp square_mat_point.h test_util.cpp test_util.h)
+
+IF(WIN32)
+   SET(testutil_src ${testutil_src} dirent.c dirent.h)
+ENDIF()
+
+add_library(testutil ${testutil_src})
 target_link_libraries(testutil bdm itpp unittest)
 
 add_executable(square_mat_stress square_mat_stress.cpp)
-target_link_libraries(square_mat_stress bdm itpp testutil unittest)
+target_link_libraries(square_mat_stress testutil unittest)
+LINK_EXEC(square_mat_stress)
 
 add_executable(square_mat_prep additive_generator.cpp additive_generator.h generator.cpp generator.h size_generator.cpp size_generator.h square_mat_prep.cpp)
-target_link_libraries(square_mat_prep bdm itpp testutil)
+target_link_libraries(square_mat_prep testutil)
+LINK_EXEC(square_mat_prep)
 
 EXEC(emix_test)
@@ -37,5 +45,6 @@
 # using UnitTest++
 add_executable(testsuite datalink_test.cpp egiw_test.cpp epdf_test.cpp loggers_test.cpp mpdf_test.cpp rv_test.cpp square_mat_test.cpp testsuite.cpp test_user_info.cpp test_shared_ptr.cpp)
-target_link_libraries(testsuite bdm itpp testutil unittest)
+target_link_libraries(testsuite testutil unittest)
+LINK_EXEC(testsuite)
 
 add_subdirectory(tutorial)
Index: library/tests/epdf_harness.cpp
===================================================================
--- library/tests/epdf_harness.cpp (revision 466)
+++ library/tests/epdf_harness.cpp (revision 469)
@@ -88,5 +88,6 @@
 	mat er = (smp * smp.T()) / nsamples - outer_product(emu, emu);
 
-	vec delta = sqrt(variance) / sqrt(nsamples);
+	// simplify overloading for Visual Studio
+	vec delta = sqrt(variance) / sqrt(static_cast<double>(nsamples));
 	CHECK_CLOSE_EX(mean, emu, delta);
 
@@ -108,5 +109,6 @@
 	vec emu = sum(smp, 2) / nsamples;
 
-	vec delta = sqrt(variance) / sqrt(nsamples);
+	// simplify overloading for Visual Studio
+	vec delta = sqrt(variance) / sqrt(static_cast<double>(nsamples));
 	CHECK_CLOSE_EX(mean, emu, delta);
 
Index: library/tests/test_util.cpp
===================================================================
--- library/tests/test_util.cpp (revision 449)
+++ library/tests/test_util.cpp (revision 469)
@@ -5,11 +5,20 @@
 #include <stdexcept>
 #include <string>
-#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <string.h>
+#include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+
+#ifdef WIN32
+#include "dirent.h"
+#include <direct.h>
+#define rmdir _rmdir
+#define unlink _unlink
+#else
+#include <dirent.h>
 #include <unistd.h>
+#endif
 
 namespace bdm {
