为什么我收到错误"无效的MEX文件",当文件在当前文件夹中?

时间:2017-01-03 15:29:46

标签: c++ matlab visual-studio-2013 mex armadillo

这是我当前的文件夹:
enter image description here
这是在文件mx_minimum_power.cpp中编写的网关函数:

#include <math.h>
#include <complex>
#include <iostream>
#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 <complex<float>> A(matrixDimention, matrixDimention);
    Mat <complex<float>> EigenVectors(matrixDimention, matrixDimention);
    Col <float> Eigenvalues(matrixDimention);
    int i = 0;
    for (i = 0; i < arraysize; i++)
    {
        A.at(0, 0) = complex<float>(inMatrixA11[i],0);
        A.at(1, 1) = complex<float>(inMatrixA22[i],0);
        A.at(2, 2) = complex<float>(inMatrixA33[i], 0);
        A.at(0, 1) = complex<float>(inMatrixA12_real[i], inMatrixA12_imag[0]);
        A.at(1, 0) = complex<float>(inMatrixA12_real[i], -inMatrixA12_imag[0]);
        A.at(0, 2) = complex<float>(inMatrixA13_real[i], inMatrixA13_imag[0]);
        A.at(2, 0) = complex<float>(inMatrixA13_real[i], -inMatrixA13_imag[0]);
        A.at(1, 2) = complex<float>(inMatrixA23_real[i], inMatrixA23_imag[0]);
        A.at(2, 1) = complex<float>(inMatrixA23_real[i], -inMatrixA23_imag[0]);
        eig_sym(Eigenvalues, EigenVectors, A);
    }
}

我通过以下代码构建了mx_minimum_power.mexw64文件:

mex -g mx_minimum_power.cpp blas_win64_MT.lib lapack_win64_MT.lib
Building with 'Microsoft Visual C++ 2013 Professional'.
MEX completed successfully.  

如您所见,所有文件Arii2011_modified.mmx_minimum_power.mexw64都在当前目录中。
但是当我运行以下功能时:

[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);  

在命令窗口中,我收到错误:

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.  

我猜这个错误与armadillo有某种关系,因为如果我将mx_minimum.cpp的第29-45行转换为注释然后重建mx_minimum_power.mexw64,我就不会出现这样的错误并且识别MEX文件

这是我通过检查依赖walker中的mx_minimum_power.mexw64文件找到的。

enter image description here

1 个答案:

答案 0 :(得分:0)

我将文件blas_win64_MT.dlllapack_win64_MT.dll添加到当前文件夹,问题得到解决 感谢@suever的评论