简体   繁体   English

当文件位于当前文件夹中时,为什么会出现错误“无效的MEX文件”?

[英]why am I getting the error “Invalid MEX-file”, while the file is in the current folder?

This is my current folder: 这是我当前的文件夹:
在此处输入图片说明
and here is the gateway function written in the file mx_minimum_power.cpp : 这是写在文件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);
    }
}

I have build the mx_minimum_power.mexw64 file through the following code: 我已经通过以下代码构建了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.  

and as you see all both of the files Arii2011_modified.m and mx_minimum_power.mexw64 are in the current directory. 如您所见,所有文件Arii2011_modified.mmx_minimum_power.mexw64都位于当前目录中。
but when I run the following function: 但是当我运行以下功能时:

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

in the command window, I get the error: 在命令窗口中,出现错误:

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.  

I guess the error is somehow related to armadillo , because if I convert lines 29-45 of the mx_minimum.cpp to comments and then rebuild the mx_minimum_power.mexw64 , I will not get such error and the MEX file is recognized 我猜错误是与armadillo有关的,因为如果我将mx_minimum.cpp第29-45行转换为注释,然后重新mx_minimum_power.mexw64 ,我将不会得到这样的错误,并且可以识别MEX文件


This is what I have found through inspecting the mx_minimum_power.mexw64 file in dependency walker. 这是通过检查依赖关系行程序中的mx_minimum_power.mexw64文件发现的。

在此处输入图片说明

我将文件blas_win64_MT.dlllapack_win64_MT.dll添加到当前文件夹中,问题得到了解决,这要归功于@suever的评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM