title: Matlab: invalid mex file library not loaded
body: <p>I have created a mex function (more specifically, using CUDA)</p>
  
  <p>the compilation was successful, and I got a <code>mex</code> file <code>zMul.mexmaci64</code></p>
  
  <p>but on the execution, matlab reported an error:</p>
  
  <pre><code>Invalid MEX-file '/Users/zlw/Documents/MATLAB/lowComplexity/cbased/matMulGPU/zMul.mexmaci64':
  dlopen(/Users/zlw/Documents/MATLAB/lowComplexity/cbased/matMulGPU/zMul.mexmaci64, 1): 
  Library not loaded: @rpath/libcublas.6.0.dylib
  Referenced from: /Users/zlw/Documents/MATLAB/lowComplexity/cbased/matMulGPU/zMul.mexmaci64
  Reason: image not found
  </code></pre>
  
  <p>What should I do do solve it?</p>
  
  <p><strong>additional info</strong></p>
  
  <ol>
  <li><p>setting the environment vars (PATH,LD_LIBRARY_PATH,DYLD_LIBRARY_PATH) in Matlab and in <code>.bash_profile</code> doesn't work for me</p></li>
  <li><p>I'm pretty sure that the environment vars are set correctly because when I created an alias to the <code>dylib</code> file, Matlab detected it, tried to load it, but failed with message:<code>no suitable image found</code></p></li>
  </ol>
  
  <p>Thanks!</p>