Index: ../trunk-jpl/m4/issm_options.m4
===================================================================
--- ../trunk-jpl/m4/issm_options.m4	(revision 18476)
+++ ../trunk-jpl/m4/issm_options.m4	(revision 18477)
@@ -271,7 +271,7 @@
   				MEXEXT=".$MEXEXT"
   			;;
 		   *)
-           MEXLINK=$(mex -v 2>&1 < /dev/null | grep LDFLAGS     | sed -e "s/         LDFLAGS            = //       g" | sed -e "s/-[[^ ]]*mexFunction\\.map//g")
+           MEXLINK=$($MATLAB_ROOT/bin/mex -v 2>&1 < /dev/null | grep LDFLAGS     | sed -e "s/         LDFLAGS            = //g")
            MEXLIB=$( $MATLAB_ROOT/bin/mex -v 2>&1 < /dev/null | grep CXXLIBS     | sed -e "s/         CXXLIBS            = //g")
 		     MEXEXT=$( $MATLAB_ROOT/bin/mex -v 2>&1 < /dev/null | grep LDEXTENSION | sed -e "s/         LDEXTENSION        = //g")
 				dnl version 2014 and up
@@ -286,6 +286,9 @@
 					 rm -f conftest.tmp
 				fi
 
+				dnl Make sure mexFunction.map is not in MEXLIB to avoid problems with global variables
+				MEXLINK=$(echo $MEXLINK | sed -e "s/-[[^ ]]*mexFunction\\.map//g")
+
   			;;
       esac
 		AC_MSG_RESULT(done)
