Compiling pardiso matlab interface finding wrong gfortran dylib

Alec Jacobson

May 28, 2014

weblog/

I tried to compile the pardiso mex interface for matlab and got a very annoying linker error upon running:

Invalid MEX-file '/Users/ajx/.../pardisoinit.mexmaci64':
dlopen(/Users/ajx/.../pardisoinit.mexmaci64, 6): Symbol
not found: __gfortran_transfer_array_write
  Referenced from: /usr/local/lib/libpardiso500-MACOS-X86-64.dylib
  Expected in: /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib
 in /usr/local/lib/libpardiso500-MACOS-X86-64.dylib

The problem seems to be that matlab is finding gfortran.3.dylib in its own directory path rather than the one that pardisoinit was linked to. These libraries are also unfortunately different. I think there's an otool/install_name_tool trick for this, but so far I'm using this hack. I replace the libgfortran.3.dylib in Matlab with the one from gcc:

mv /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib.off
cp /opt/local/lib/libgcc/libgfortran.3.dylib /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib

So far this hasn't messed up anything else in MATLAB, but I guess, without knowing better, it's only a matter of luck. Too bad pardiso doesn't seem to support mac and isn't open source.