diff -Naur vlfeat-0.9.20.orig/make/bin.mak vlfeat-0.9.20/make/bin.mak
--- vlfeat-0.9.20.orig/make/bin.mak	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/make/bin.mak	2017-11-07 18:40:36.454700600 +0800
@@ -44,6 +44,16 @@
 BIN_LDFLAGS += -Wl,--rpath,\$$ORIGIN/
 endif
 
+# MingW-32
+ifeq ($(ARCH),mingw32)
+BIN_LDFLAGS += -Wl,--rpath,\$$ORIGIN/
+endif
+
+# MingW-64
+ifeq ($(ARCH),mingw64)
+BIN_LDFLAGS += -Wl,--rpath,\$$ORIGIN/
+endif
+
 # --------------------------------------------------------------------
 #                                                                Build
 # --------------------------------------------------------------------
diff -Naur vlfeat-0.9.20.orig/make/dll.mak vlfeat-0.9.20/make/dll.mak
--- vlfeat-0.9.20.orig/make/dll.mak	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/make/dll.mak	2017-11-07 18:40:36.469701500 +0800
@@ -76,6 +76,18 @@
 DLL_LDFLAGS += -m64
 endif
 
+# MingW-32
+ifeq ($(ARCH),mingw32)
+DLL_SUFFIX := dll
+DLL_LDFLAGS += -m32
+endif
+
+# MingW-64
+ifeq ($(ARCH),mingw64)
+DLL_SUFFIX := dll
+DLL_LDFLAGS += -m64
+endif
+
 # --------------------------------------------------------------------
 #                                                                Build
 # --------------------------------------------------------------------
@@ -137,6 +149,13 @@
 	    $(^)                                                \
 	    $(DLL_LDFLAGS)	                                \
 	    -o "$(@)"
+	    
+$(BINDIR)/lib$(DLL_NAME).dll : $(dll_obj)
+	$(call C,CC) -shared  \
+	    -Wl,--output-def,$(BINDIR)/lib$(DLL_NAME).def,--out-implib,$(BINDIR)/lib$(DLL_NAME).dll.a \
+	    $(^)                                                \
+	    $(DLL_LDFLAGS)	                                \
+	    -o "$(@)"
 
 dll-clean:
 	rm -f $(dll_dep) $(dll_obj)
diff -Naur vlfeat-0.9.20.orig/Makefile vlfeat-0.9.20/Makefile
--- vlfeat-0.9.20.orig/Makefile	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/Makefile	2017-11-07 18:43:26.283414300 +0800
@@ -92,6 +92,13 @@
 
 SHELL = /bin/bash
 
+prefix = /usr/local
+vlfeatprefix = ${prefix}
+bindir = ${vlfeatprefix}/bin
+libdir = ${vlfeatprefix}/lib
+includedir = ${vlfeatprefix}/include
+
+
 .PHONY : all
 all:
 
@@ -100,6 +107,7 @@
 # DISABLE_AVX=yes
 # DISABLE_THREADS=yes
 # DISABLE_OPENMP=yes
+DISABLE_MATLAB=yes
 
 # --------------------------------------------------------------------
 #                                                       Error Messages
@@ -121,7 +129,10 @@
 # --------------------------------------------------------------------
 #                                             Auto-detect architecture
 # --------------------------------------------------------------------
-
+MINGW32_NT-6.1_i386_ARCH := mingw32
+MINGW32_NT-6.1_x86_64_ARCH := mingw32
+MINGW64_NT-6.1_i386_ARCH := mingw64
+MINGW64_NT-6.1_x86_64_ARCH := mingw64
 Darwin_PPC_ARCH := mac
 Darwin_Power_Macintosh_ARCH := mac
 Darwin_i386_ARCH := maci64
@@ -326,11 +335,30 @@
 
 include make/dll.mak
 include make/bin.mak
+ifeq "$(DISABLE_MATLAB)" "no"
 include make/matlab.mak
+endif
 include make/octave.mak
 include make/doc.mak
 include make/dist.mak
 
+install:
+	@rm -rf $(DESTDIR)$(vlfeatprefix)
+	@if [ ! -d $(DESTDIR)$(vlfeatprefix)   ]; then mkdir -p $(DESTDIR)$(vlfeatprefix); fi
+	@if [ ! -d $(DESTDIR)$(bindir)   ]; then mkdir -p $(DESTDIR)$(bindir); fi
+	@if [ ! -d $(DESTDIR)$(includedir)   ]; then mkdir -p $(DESTDIR)$(includedir); fi
+	@if [ ! -d $(DESTDIR)$(libdir)   ]; then mkdir -p $(DESTDIR)$(libdir); fi
+	@if [ ! -d $(DESTDIR)$(includedir)/vl ]; then mkdir -p $(DESTDIR)$(includedir)/vl; fi
+	cp vl/*.h $(DESTDIR)$(includedir)/vl
+	cp bin/$(ARCH)/libvl.dll $(DESTDIR)$(bindir)
+	cp bin/$(ARCH)/*.exe $(DESTDIR)$(bindir)
+	cp bin/$(ARCH)/*.a $(DESTDIR)$(libdir)
+
+uninstall:
+		@rm -rf $(DESTDIR)$(vlfeatprefix)
+	
+
+
 clean:
 	rm -f  `find . -name '*~'`
 	rm -f  `find . -name '.DS_Store'`
diff -Naur vlfeat-0.9.20.orig/src/mser.c vlfeat-0.9.20/src/mser.c
--- vlfeat-0.9.20.orig/src/mser.c	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/src/mser.c	2017-11-07 18:40:36.513704000 +0800
@@ -20,8 +20,12 @@
 #include <vl/stringop.h>
 #include <vl/pgm.h>
 #include <vl/mser.h>
-#include <vl/getopt_long.h>
 
+#if defined(__MINGW64__) || defined(__MINGW32__)
+#include <getopt.h>
+#else
+#include <vl/getopt_long.h>
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
diff -Naur vlfeat-0.9.20.orig/src/sift.c vlfeat-0.9.20/src/sift.c
--- vlfeat-0.9.20.orig/src/sift.c	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/src/sift.c	2017-11-07 18:40:36.534705200 +0800
@@ -20,7 +20,11 @@
 #include <vl/stringop.h>
 #include <vl/pgm.h>
 #include <vl/sift.h>
+#if defined(__MINGW64__) || defined(__MINGW32__)
+#include <getopt.h>
+#else
 #include <vl/getopt_long.h>
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
diff -Naur vlfeat-0.9.20.orig/src/test_getopt_long.c vlfeat-0.9.20/src/test_getopt_long.c
--- vlfeat-0.9.20.orig/src/test_getopt_long.c	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/src/test_getopt_long.c	1970-01-01 08:00:00.000000000 +0800
@@ -1,85 +0,0 @@
-/*
-Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
-All rights reserved.
-
-This file is part of the VLFeat library and is made available under
-the terms of the BSD license (see the COPYING file).
-*/
-
-#include <stdio.h>
-#include <assert.h>
-
-#include <vl/getopt_long.h>
-
-int daggerset;
-
-/* options descriptor */
-static struct option longopts[] = {
-  { "help",         no_argument,            0,           'h' },
-  { "buffy",        no_argument,            0,           'b' },
-  { "fluoride",     required_argument,      0,           'f' },
-  { "daggerset",    no_argument,            &daggerset,   1000  },
-  { "daggerunset",  no_argument,            &daggerset,   1001  },
-  { "spike",        optional_argument,      0,            1002  },
-  { NULL,           0,                      0,            0  }
-};
-
-int
-main (int argc, char *argv[])
-{
-  int ch ;
-
-  printf("*** parsing options: start\n") ;
-
-  while ((ch = getopt_long(argc, argv, "hbf:", longopts, 0)) != -1) {
-
-    switch (ch) {
-
-    case 'h':
-        printf("test_getopt_long: test VLFeat implementation of this function.\n"
-               " --help -h      this message\n"
-               " --buffy -b     option with no arguments\n"
-               " --fluoride -f  option with required argument\n"
-               " --daggerset    auto option with no arguments\n"
-               " --daggerrunset auto option with no argument\n"
-               " --spike        long option with optional argument\n") ;
-        break;
-
-    case 'b':
-      printf("option `b' or `buffy'\n") ;
-      break;
-
-    case 'f':
-      printf("option `f' or `flouride' with arg `%s'\n", optarg) ;
-      break ;
-
-    case 1002 :
-      printf("option `spike' with arg `%s'\n", optarg) ;
-      break ;
-
-    case 0:
-      printf("automatic longoption (daggerset=%d)\n", daggerset) ;
-      break ;
-
-    case  '?' :
-      printf("illegal option or missing argument\n") ;
-      break ;
-
-    case ':'  :
-      printf("illegal option\n") ;
-      break ;
-
-    default:
-      abort() ;
-    }
-  }
-
-  printf("*** parsing options: end\n");
-  {
-    int i ;
-    for(i = optind ; i < argc ; ++i)
-		printf("non-option: '%s'\n", argv[i]) ;
-  }
-
-  return 0 ;
-}
diff -Naur vlfeat-0.9.20.orig/vl/getopt_long.c vlfeat-0.9.20/vl/getopt_long.c
--- vlfeat-0.9.20.orig/vl/getopt_long.c	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/vl/getopt_long.c	1970-01-01 08:00:00.000000000 +0800
@@ -1,326 +0,0 @@
-/** @file getopt_long.c
- ** @brief getopt_long - Definition
- ** @author Andrea Vedaldi
- **/
-
-/*
-Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
-All rights reserved.
-
-This file is part of the VLFeat library and is made available under
-the terms of the BSD license (see the COPYING file).
-*/
-
-/**
-@file   getopt_long.h
-@brief  getopt_long
-@author Andrea Vedaldi
-
-This is a drop-in replacament of GNU getopt_long meant to be used
-on platforms that do not support such functionality.
-**/
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "generic.h"
-#include "getopt_long.h"
-
-int    opterr = 1 ;
-int    optind = 1 ;
-int    optopt ;
-char * optarg ;
-int    optreset ;
-
-#define BADCH	'?'
-#define BADARG	':'
-#define EEND    -1
-#define EMSG	""
-
-/** @brief Parse long options (BSD style)
- ** @param argc number of arguments.
- ** @param argv pointer to the vector of arguments.
- ** @param optstring list of abbreviated options
- ** @param longopts list of long options.
- ** @param longindex index of current option in @a longopts.
- ** @return the code of the next option.
- **
- ** This function extract long and short options from the argument
- ** list @a argv of @a argc entries.
- **
- ** A short options sequence is introduced by a single dash character
- ** @c -. Each short option is described by a single character in the
- ** string @a optstring, possibly followed by a @c : character to
- ** denote a (mandatory) argument of the short option. A short option
- ** with an argument cannot appear in the middle of a short option
- ** sequence, but only at the end.
- **
- ** A long option is introduced by a double dash @c --. Each long
- ** option is described by an instance of the ::option structure in
- ** the @a longopts table (the last entry must be filled with zeroes
- ** to denote the end).
- **
- ** Illegal options and missing arguments cause the function to skip
- ** the option and return '?'. If ::opterr is @c true (default), the
- ** function prints an error message to @a stderr. Finally, if @a
- ** optstring has a leading @c :, then error messages are suppressed
- ** and a missing argument causes @a : to be returned.
- **
- ** @remark The function is currently <em>not</em> thread safe.
- **/
-
-VL_EXPORT int
-getopt_long(int argc, char *const argv[],
-            const char *optstring,
-            const struct option * longopts,
-            int *longindex)
-{
-  static char *place = EMSG;	/* option letter processing */
-  static int   optbegin  = 0 ;
-  static int   optend    = 0 ;
-  char        *oli;		/* option letter list index */
-  int          has_colon = 0 ;
-  int          ret_val   = 0 ;
-
-  /*
-     A semicolon at the beginning of optstring has a special meaning.
-     If we find one, we annote and remove it.
-  */
-  has_colon = optstring && optstring[0] == ':' ;
-  if (has_colon) ++ optstring ;
-
-  /*
-   Here we are either processing a short option sequence or
-   we start processing a new option. This is indicated by optreset.
-  */
-
-  if (optreset || *place == '\0') {
-
-    /* ---------------------------------------------------------------
-     *                                 Look for next short/long option
-     * ------------------------------------------------------------ */
-    optreset = 0 ;
-
-    /* no more arguments ? */
-    if (optind >= argc) {
-      place = EMSG ;
-      return -1 ;
-    }
-
-    /* next argument that may hold an option */
-    optbegin = optind ;
-
-    /* ---------------------------------------------------------------
-     *                                     Look for an option to parse
-     * ------------------------------------------------------------ */
-
-  parse_option_at_optbegin :
-
-    /* place points to the candidate option */
-    place = argv [optbegin] ;
-
-    /* an option is introduced by '-' */
-    if (place [0] != '-') {
-      /* this argument is not an option: try next argument */
-      ++ optbegin ;
-      if (optbegin >= argc) {
-        /* no more arguments to look for options */
-        place = EMSG ;
-        return -1 ;
-      }
-      goto parse_option_at_optbegin ;
-    }
-
-    /* consume leading `-' */
-    ++ place ;
-
-    /* assume the option is composed of one argument only */
-    optend = optbegin + 1 ;
-
-    /* assume no argument */
-    optarg = 0 ;
-
-    /* ---------------------------------------------------------------
-     *                                                     option `--'
-     * ------------------------------------------------------------ */
-
-    /* this special option (void long option) ends the option processing */
-    if (place[0]        &&
-        place[0] == '-' &&
-        place[1] == '\0') {
-
-      optind  = optend ;
-      place   = EMSG ;
-      ret_val = -1 ;
-      goto done_option ;
-    }
-
-    /* ---------------------------------------------------------------
-     *                                                     long option
-     * ------------------------------------------------------------ */
-
-    if (place[0]        &&
-        place[0] == '-' &&
-        place[1] ) {
-
-      size_t namelen ;
-      int i ;
-
-      /* consume second `-' */
-      ++ place ;
-
-      /* count characters before `=' */
-      namelen = strcspn(place, "=") ;
-
-      /* scan longopts for this option */
-      for (i = 0 ; longopts[i].name != NULL ; ++ i) {
-
-        if (strlen  (       longopts[i].name) == namelen &&
-            strncmp (place, longopts[i].name, namelen) == 0 ) {
-
-          /* save back long option index */
-          if (longindex) *longindex = i ;
-
-          /* process long option argument */
-          if (longopts[i].has_arg == required_argument ||
-              longopts[i].has_arg == optional_argument) {
-
-            /* --option=value style */
-            if (place[namelen] == '=') {
-              optarg = place + namelen + 1 ;
-            }
-
-            /* --option value style (only required_argument) */
-            else if (longopts[i].has_arg == required_argument) {
-              /* missing argument ? */
-              if (optbegin >= argc - 1) {
-                if (! has_colon && opterr)
-                  fprintf(stderr,
-                          "%s: option requires an argument -- %s\n",
-                          argv[0], place);
-                place   = EMSG ;
-                ret_val = has_colon ? BADARG : BADCH ;
-                goto done_option ;
-              }
-              optarg = argv [optend] ;
-              ++ optend ;
-            }
-          }
-
-          /* determine return value */
-          if (longopts[i].flag == NULL) {
-            ret_val = longopts[i].val ;
-          }
-          else {
-            *longopts[i].flag = longopts[i].val;
-            ret_val = 0 ;
-          }
-
-          /* mark sequence closed */
-          place = EMSG ;
-          goto done_option ;
-        } /* if match */
-
-      } /* scan longoptions */
-
-      /* no matching option found */
-      if (! has_colon && opterr)
-        fprintf(stderr,
-                "%s: illegal option -- %s\n", argv[0], place) ;
-      place   = EMSG ;
-      ret_val = BADCH ;
-      goto done_option ;
-    }
-  } /* end new option */
-
-  /* -----------------------------------------------------------------
-   *                                      Finish short option sequence
-   * -------------------------------------------------------------- */
-  optopt = (int) *place++ ;
-
-  /* search charcater in option list */
-  oli = strchr(optstring, optopt);
-
-  /* short option not found */
-  if (!oli) {
-
-    if (! has_colon && opterr)
-      fprintf(stderr,
-              "%s: illegal option -- %c\n",
-              argv[0], optopt);
-
-    if (*place) {
-      /* more short options in the list */
-      return BADCH ;
-    }
-
-    else {
-      /* error occured as last option in the list */
-      place   = EMSG ;
-      ret_val = BADCH ;
-      goto done_option ;
-    }
-  } /* end short option not found */
-
-  if (oli[1] != ':') {
-    /* short option with no argument */
-
-    if (*place) {
-      /* more short options in the list */
-      return optopt ;
-    }
-    else {
-      /* last option in the list */
-      place   = EMSG ;
-      ret_val = optopt ;
-      goto done_option ;
-    }
-
-  } else {
-    /* short option with argument */
-
-    /* -ovalue style */
-    if (*place) {
-      optarg  = place ;
-      place   = EMSG ;
-      ret_val = optopt ;
-      goto done_option ;
-    }
-    /* -o value style: missing argument */
-    else if (optbegin >= argc - 1) {
-      if (! has_colon && opterr)
-        fprintf(stderr,
-                "%s: option requires an argument -- %c\n",
-                argv[0], optopt);
-      place   = EMSG ;
-      ret_val = has_colon ? BADARG : BADCH ;
-      goto done_option ;
-    }
-
-    /* -o value style: process argument */
-    optarg = argv [optend] ;
-    ++ optend ;
-    place   = EMSG ;
-    ret_val = optopt ;
-    goto done_option ;
-  } /* short with argument */
-
- done_option :
-  {
-    int pos = optend - optbegin ;  /* n of circular shifts */
-    int c   = pos ;
-
-    while (c --) {
-      int i ;
-      char *tmp = argv [optend - 1] ;
-      for (i = optend - 1 ; i > optind ; -- i) {
-        ((char**)argv) [i] = argv [i-1] ;
-      }
-      ((char**)argv) [optind] = tmp ;
-    }
-    optind += pos ;
-  }
-
-  return ret_val ;
-}
diff -Naur vlfeat-0.9.20.orig/vl/getopt_long.h vlfeat-0.9.20/vl/getopt_long.h
--- vlfeat-0.9.20.orig/vl/getopt_long.h	2015-01-16 02:30:34.000000000 +0800
+++ vlfeat-0.9.20/vl/getopt_long.h	1970-01-01 08:00:00.000000000 +0800
@@ -1,43 +0,0 @@
-/** @file getopt_long.h
- ** @brief getopt_long
- ** @author Andrea Vedaldi
- **/
-
-/*
-Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
-All rights reserved.
-
-This file is part of the VLFeat library and is made available under
-the terms of the BSD license (see the COPYING file).
-*/
-
-#ifndef VL_GETOPT_LONG_H
-#define VL_GETOPT_LONG_H
-
-#include "generic.h"
-
-VL_EXPORT int    opterr ;   /**< code of the last error occured while parsing an option */
-VL_EXPORT int    optind ;   /**< index of the next option to process in @c argv */
-VL_EXPORT int    optopt ;   /**< current option */
-VL_EXPORT char * optarg ;   /**< argument of the current option */
-VL_EXPORT int    optreset ; /**< reset flag */
-
-/** @brief ::getopt_long option */
-struct option
-{
-  const char *name ;  /**< option long name */
-  int	      has_arg ; /**< flag indicating whether the option has no, required or optional argument */
-  int	     *flag ;    /**< pointer to a variable to set (if @c NULL, the value is returned instead) */
-  int	      val ;     /**< value to set or to return */
-} ;
-
-#define no_argument       0 /**< ::option with no argument */
-#define required_argument 1 /**< ::option with required argument */
-#define optional_argument 2 /**< ::option with optional argument */
-
-VL_EXPORT int getopt_long(int argc, char * const argv[],
-                          const char * optstring,
-                          const struct option * longopts, int * longindex);
-
-/* VL_GETOPT_LONG_H */
-#endif
