diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 55f804cfdb04b479a12ea6995ab9344c714f1a1b..75a798273fe78611fd07601f61ea54f30b017b41 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -372,7 +372,7 @@ DynamicModel::writeDynamicPerBlockCFiles(const string &basename, const string &m
       ofstream output{filename, ios::out | ios::binary};
       if (!output.is_open())
         {
-          cerr << "ERROR: Can't open file " << filename << " for writing" << endl;
+          cerr << "ERROR: Can't open file " << filename.string() << " for writing" << endl;
           exit(EXIT_FAILURE);
         }
 
@@ -543,7 +543,7 @@ DynamicModel::writeDynamicPerBlockCFiles(const string &basename, const string &m
       ofstream header_output{filename, ios::out | ios::binary};
       if (!header_output.is_open())
         {
-          cerr << "ERROR: Can't open file " << filename << " for writing" << endl;
+          cerr << "ERROR: Can't open file " << filename.string() << " for writing" << endl;
           exit(EXIT_FAILURE);
         }
       header_output << header.str() << ';' << endl;
@@ -4605,7 +4605,7 @@ DynamicModel::isChecksumMatching(const string &basename) const
   checksum_file.open(filename, ios::out | ios::binary);
   if (!checksum_file.is_open())
     {
-      cerr << "ERROR: Can't open file " << filename << endl;
+      cerr << "ERROR: Can't open file " << filename.string() << endl;
       exit(EXIT_FAILURE);
     }
   checksum_file << result;
diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index 0bd7039523270416847a70e05105d56b77372d95..c2eb674cf8e07ea9d5060f1c090af2917305944a 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -1759,7 +1759,7 @@ ModelTree::compileMEX(const filesystem::path &output_dir, const string &output_b
   cmd << '"';
 #endif
 
-  cout << "Compiling " << output_filename << endl;
+  cout << "Compiling " << output_filename.string() << endl;
 
   // The prerequisites are the object files among the input files
   set<filesystem::path> prerequisites;
diff --git a/src/ModelTree.hh b/src/ModelTree.hh
index 08bf4d81c50b6d46bb56c0ff2afebc7bd08024ee..e2e2884983bf470e8d6a7a759c55bf15abd12f93 100644
--- a/src/ModelTree.hh
+++ b/src/ModelTree.hh
@@ -837,7 +837,7 @@ ModelTree::writeModelCFile(const string &basename, const string &mexext,
     output.open(p, ios::out | ios::binary);
     if (!output.is_open())
       {
-        cerr << "ERROR: Can't open file " << p << " for writing" << endl;
+        cerr << "ERROR: Can't open file " << p.string() << " for writing" << endl;
         exit(EXIT_FAILURE);
       }
   };
diff --git a/src/StaticModel.cc b/src/StaticModel.cc
index dde18cb9ccedd53f6caff370bceff911c4d832c6..b01230b5ebf69a3b32c415515a8a151b18d2e9df 100644
--- a/src/StaticModel.cc
+++ b/src/StaticModel.cc
@@ -167,7 +167,7 @@ StaticModel::writeStaticPerBlockCFiles(const string &basename, const string &mex
       ofstream output{filename, ios::out | ios::binary};
       if (!output.is_open())
         {
-          cerr << "ERROR: Can't open file " << filename << " for writing" << endl;
+          cerr << "ERROR: Can't open file " << filename.string() << " for writing" << endl;
           exit(EXIT_FAILURE);
         }
       output << "/* Block " << blk+1 << endl