title: why am I getting the error "Invalid MEX-file", while the file is in the current folder?
body: <p>This is my current folder:<br>
  <a href="https://i.stack.imgur.com/TMyzR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMyzR.png" alt="enter image description here"></a><br>
  and here is the gateway function written in the file <code>mx_minimum_power.cpp</code>:  </p>
  
  <pre><code>#include &lt;math.h&gt;
  #include &lt;complex&gt;
  #include &lt;iostream&gt;
  #include "mex.h"
  #include "matrix.h"
  #include "armaMex.hpp"
  
  using std::complex;
  using std::cout;
  using std::endl;
  
  
  /* The gateway function */
  void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
  {
      double *arraysizePtr = NULL;
      arraysizePtr = mxGetPr(prhs[9]);
      const int arraysize = (int)*arraysizePtr;
      const int matrixDimention = 3;
      float *inMatrixA11 = (float *)mxGetPr(prhs[0]);
      float *inMatrixA12_real = (float *)mxGetPr(prhs[1]);
      float *inMatrixA12_imag = (float *)mxGetPr(prhs[2]);
      float *inMatrixA13_real = (float *)mxGetPr(prhs[3]);
      float *inMatrixA13_imag = (float *)mxGetPr(prhs[4]);
      float *inMatrixA22 = (float *)mxGetPr(prhs[5]);
      float *inMatrixA23_real = (float *)mxGetPr(prhs[6]);
      float *inMatrixA23_imag = (float *)mxGetPr(prhs[7]);
      float *inMatrixA33 = (float *)mxGetPr(prhs[8]);
      Mat &lt;complex&lt;float&gt;&gt; A(matrixDimention, matrixDimention);
      Mat &lt;complex&lt;float&gt;&gt; EigenVectors(matrixDimention, matrixDimention);
      Col &lt;float&gt; Eigenvalues(matrixDimention);
      int i = 0;
      for (i = 0; i &lt; arraysize; i++)
      {
          A.at(0, 0) = complex&lt;float&gt;(inMatrixA11[i],0);
          A.at(1, 1) = complex&lt;float&gt;(inMatrixA22[i],0);
          A.at(2, 2) = complex&lt;float&gt;(inMatrixA33[i], 0);
          A.at(0, 1) = complex&lt;float&gt;(inMatrixA12_real[i], inMatrixA12_imag[0]);
          A.at(1, 0) = complex&lt;float&gt;(inMatrixA12_real[i], -inMatrixA12_imag[0]);
          A.at(0, 2) = complex&lt;float&gt;(inMatrixA13_real[i], inMatrixA13_imag[0]);
          A.at(2, 0) = complex&lt;float&gt;(inMatrixA13_real[i], -inMatrixA13_imag[0]);
          A.at(1, 2) = complex&lt;float&gt;(inMatrixA23_real[i], inMatrixA23_imag[0]);
          A.at(2, 1) = complex&lt;float&gt;(inMatrixA23_real[i], -inMatrixA23_imag[0]);
          eig_sym(Eigenvalues, EigenVectors, A);
      }
  }
  </code></pre>
  
  <p>I have build the <code>mx_minimum_power.mexw64</code> file through the following code:  </p>
  
  <pre><code>mex -g mx_minimum_power.cpp blas_win64_MT.lib lapack_win64_MT.lib
  Building with 'Microsoft Visual C++ 2013 Professional'.
  MEX completed successfully.  
  </code></pre>
  
  <p>and as you see all both of the files <code>Arii2011_modified.m</code> and <code>mx_minimum_power.mexw64</code> are in the current directory.<br>
  but when I run the following function:  </p>
  
  <pre><code>[Ps,Pd,Pv,ThetaMean,Variance] = Arii2011_Modified(MMA.Data.C11,MMA.Data.C12_imag,MMA.Data.C12_real,MMA.Data.C13_imag,MMA.Data.C13_real,MMA.Data.C22,MMA.Data.C23_imag,MMA.Data.C23_real,MMA.Data.C33);  
  </code></pre>
  
  <p>in the command window, I get the error:  </p>
  
  <pre><code>Invalid MEX-file 'D:\thesis library.Data\ALOS-PALSAR 12x2\San Francisco L
  12x2\mx_minimum_power.mexw64': The specified module could not be found.  
  </code></pre>
  
  <p>I guess the error is somehow related to <code>armadillo</code>, because if I convert lines 29-45 of the <code>mx_minimum.cpp</code> to comments and then rebuild the <code>mx_minimum_power.mexw64</code>, I will not get such error and the MEX file is recognized  </p>
  
  <hr>
  
  <p>This is what I have found through inspecting the <code>mx_minimum_power.mexw64</code> file in dependency walker.</p>
  
  <p><a href="https://i.stack.imgur.com/6e8Hf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6e8Hf.png" alt="enter image description here"></a></p>