diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index 6d9710960e8cccbcc98628180ceb31ae980721ed..5090649cf5dfe5dc98243e3da2ec02efe2e3f98e 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -297,7 +297,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
   // Compile the dynamic MEX file for use_dll option
   if (use_dll)
     mOutputFile << "if ~exist('OCTAVE_VERSION')" << endl
-                << "  eval('mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' " << basename << "_dynamic.c')" << endl // This command is enclosed in an eval(), because otherwise it will make Octave fail
+                << "  eval('mex -O LINKER=''echo EXPORTS > mex.def & echo mexFunction & echo Dynamic >> mex.def & gcc-3'' LDFLAGS=''-pthread -shared -Wl,--no-undefined'' " << basename << "_dynamic.c')" << endl // This command is enclosed in an eval(), because otherwise it will make Octave fail
                 << "else" << endl
                 << "  mex "  << basename << "_dynamic.c" << endl
                 << "end" << endl;