From 8a879930001e270f2c7e3f020f746364452c28af Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Mon, 30 Nov 2009 16:36:00 +0000
Subject: [PATCH] preprocessor: fixed option "use_dll" (and therefore
 "k_order_solver") for Octave

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3178 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 ModFile.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ModFile.cc b/ModFile.cc
index 7201dc28..f39e4909 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -297,7 +297,11 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
 
   // Compile the dynamic MEX file for use_dll option
   if (use_dll)
-    mOutputFile << "mex -O LDFLAGS='-pthread -shared -Wl,--no-undefined' " << basename << "_dynamic.c" << endl;
+    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
+                << "else" << endl
+                << "  mex "  << basename << "_dynamic.c" << endl
+                << "end" << endl;
 
   // Add path for block option with M-files
   if (block && !byte_code)
-- 
GitLab