diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc
index 0c81f00d0f68b24db84f2bfe7ecce0a8c833ba8f..adbb1b6821f2afdcc799949a6f99d16d1699406a 100644
--- a/preprocessor/DynareMain.cc
+++ b/preprocessor/DynareMain.cc
@@ -42,8 +42,8 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
            WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes,
            bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
            LanguageOutputType lang, int params_derivs_order
-#if defined(_WIN32) || defined(__CYGWIN32__)
-           , bool cygwin, bool msvc
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+           , bool cygwin, bool msvc, bool mingw
 #endif
            );
 
@@ -58,8 +58,8 @@ usage()
        << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
        << " [-D<variable>[=<value>]] [-I/path] [nostrict] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]"
        << " [params_derivs_order=0|1|2]"
-#if defined(_WIN32) || defined(__CYGWIN32__)
-       << " [cygwin] [msvc]"
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+       << " [cygwin] [msvc] [mingw]"
 #endif
        << endl;
   exit(EXIT_FAILURE);
@@ -96,9 +96,10 @@ main(int argc, char **argv)
   bool console = false;
   bool nograph = false;
   bool nointeractive = false;
-#if defined(_WIN32) || defined(__CYGWIN32__)
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
   bool cygwin = false;
   bool msvc = false;
+  bool mingw = false;
 #endif
   string parallel_config_file;
   bool parallel = false;
@@ -167,11 +168,13 @@ main(int argc, char **argv)
         nograph = true;
       else if (!strcmp(argv[arg], "nointeractive"))
         nointeractive = true;
-#if defined(_WIN32) || defined(__CYGWIN32__)
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
       else if (!strcmp(argv[arg], "cygwin"))
         cygwin = true;
       else if (!strcmp(argv[arg], "msvc"))
         msvc = true;
+      else if (!strcmp(argv[arg], "mingw"))
+        mingw = true;
 #endif
       else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "conffile", 8))
         {
@@ -331,8 +334,8 @@ main(int argc, char **argv)
         no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
         parallel, config_file, warnings, nostrict, check_model_changes, minimal_workspace,
         compute_xrefs, output_mode, language, params_derivs_order
-#if defined(_WIN32) || defined(__CYGWIN32__)
-        , cygwin, msvc
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+        , cygwin, msvc, mingw
 #endif
         );
 
diff --git a/preprocessor/DynareMain2.cc b/preprocessor/DynareMain2.cc
index a023328e439f3fad2ce7e5b3791c95cf6d235782..7d867831b690651765fbda20f48d12a17a94893d 100644
--- a/preprocessor/DynareMain2.cc
+++ b/preprocessor/DynareMain2.cc
@@ -31,8 +31,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
       WarningConsolidation &warnings, bool nostrict, bool check_model_changes,
       bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
       LanguageOutputType language, int params_derivs_order
-#if defined(_WIN32) || defined(__CYGWIN32__)
-      , bool cygwin, bool msvc
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+      , bool cygwin, bool msvc, bool mingw
 #endif
       )
 {
@@ -59,8 +59,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
   else
     mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
                                nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs
-#if defined(_WIN32) || defined(__CYGWIN32__)
-			       , cygwin, msvc
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+			       , cygwin, msvc, mingw
 #endif
 			       );
 
diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index 2ce6eb37c046a1f3c75833c6d941dff2ea907fcd..71f71c991c17c9e5d51a8d6998bda1469445c5d1 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -561,7 +561,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
                           bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
                           bool check_model_changes, bool minimal_workspace, bool compute_xrefs
 #if defined(_WIN32) || defined(__CYGWIN32__)
-                          , bool cygwin, bool msvc
+                          , bool cygwin, bool msvc, bool mingw
 #endif
                           ) const
 {
@@ -723,22 +723,22 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
     {
       if (dynamic_model.isUnaryOpUsed(oAcosh))
         {
-          cerr << "ERROR: acosh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl;
+          cerr << "ERROR: acosh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl;
           exit(EXIT_FAILURE);
         }
       if (dynamic_model.isUnaryOpUsed(oAsinh))
         {
-          cerr << "ERROR: asinh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl;
+          cerr << "ERROR: asinh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl;
           exit(EXIT_FAILURE);
         }
       if (dynamic_model.isUnaryOpUsed(oAtanh))
         {
-          cerr << "ERROR: atanh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl;
+          cerr << "ERROR: atanh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl;
           exit(EXIT_FAILURE);
         }
       if (dynamic_model.isTrinaryOpUsed(oNormcdf))
         {
-          cerr << "ERROR: normcdf() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl;
+          cerr << "ERROR: normcdf() function is not supported with USE_DLL option and MSVC compiler; use Cygwin MinGW compiler instead." << endl;
           exit(EXIT_FAILURE);
         }
     }
@@ -748,15 +748,18 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
   // When check_model_changes is true, don't force compile if MEX is fresher than source
   if (use_dll)
     {
-#if defined(_WIN32) || defined(__CYGWIN32__)
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
       if (msvc)
         // MATLAB/Windows + Microsoft Visual C++
 	mOutputFile << "dyn_mex('msvc', '" << basename << "', " << !check_model_changes << ")" <<  endl;
       else if (cygwin)
         // MATLAB/Windows + Cygwin g++
 	mOutputFile << "dyn_mex('cygwin', '" << basename << "', " << !check_model_changes << ")" << endl;
+      else if (mingw)
+        // MATLAB/Windows + MinGW g++
+        mOutputFile << "dyn_mex('mingw', '" << basename << "', " << !check_model_changes << ")" << endl;
       else
-        mOutputFile << "    error('When using the USE_DLL option, you must give either ''cygwin'' or ''msvc'' option to the ''dynare'' command')" << endl;
+        mOutputFile << "    error('When using the USE_DLL option, you must give the ''cygwin'', ''msvc'', or ''mingw'' option to the ''dynare'' command')" << endl;
 #else
       // other configurations
       mOutputFile << "dyn_mex('', '" << basename << "', " << !check_model_changes << ")" << endl;
diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh
index 4635ac1c2ac77a925311558fe76dd87038271ff8..3dcfebc5e834ecf15d6478cb53ffccedcf55d8b9 100644
--- a/preprocessor/ModFile.hh
+++ b/preprocessor/ModFile.hh
@@ -143,13 +143,14 @@ public:
     \param nointeractive Should Dynare request user input?
     \param cygwin Should the MEX command of use_dll be adapted for Cygwin?
     \param msvc Should the MEX command of use_dll be adapted for MSVC?
+    \param mingw Should the MEX command of use_dll be adapted for MinGW?
     \param compute_xrefs if true, equation cross references will be computed
   */
   void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn,
                         bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
                         bool check_model_changes, bool minimal_workspace, bool compute_xrefs
-#if defined(_WIN32) || defined(__CYGWIN32__)
-                        , bool cygwin, bool msvc
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                        , bool cygwin, bool msvc, bool mingw
 #endif
                         ) const;
   void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const;