invalid mex-file specified procedure could not be found

조회 수: 9 (최근 30일)
Kristopher
Kristopher 2014년 2월 14일
댓글: Friedrich 2014년 3월 5일
Hi everyone,
I am trying create a mex file that will use some C code to parse a xml file and return the data to matlab. The C code uses the libxml2 libraries.
The C code compiles and runs fine in visual studio.
When matlab uses the VS compiler (via mex -setup) the mex file will compile fine. How ever when running the mex file I get the following error.
Invalid MEX-file myMexFile: The specified procedure could not be found.
If I remove the line that calls for the file to be parsed (allData = parseFile(docname);) the mex file will run without issue.
I have tried running the mex file through dependency walker and I get a bunch of dll files that are missing. However when removing the parsing code from the mex file I still have dlls missing and the program still runs without any errors.
I think it must be something to do with matlab unable to find library/dll files or finding duplicates and unable to determine which to use.
here is the mexfile code
#include "mex.h" #include "xmlParseFromMex.h"
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
int x;
OutputData allData;
double tmp1;
char *docname;
mwSize buflen;
int status;
(void) plhs; /* unused parameters */
/* Check for proper number of input and output arguments */
if (nrhs != 1) {
mexErrMsgTxt("One input argument required.");
}
if (nlhs > 1) {
mexErrMsgTxt("Too many output arguments.");
}
/* Check for proper input type */
if (!mxIsChar(prhs[0]) || (mxGetM(prhs[0]) != 1 ) ) {
mexErrMsgTxt("Input argument must be a string.");
}
buflen = mxGetN(prhs[0])*sizeof(mxChar)+1;
docname = mxMalloc(buflen);
/* Copy the string data into buf. */
status = mxGetString(prhs[0], docname, buflen);
mexPrintf("The input string is: %s\n", docname);
//parse the xml file and returnt he data
allData = parseFile(docname);
mexPrintf("made it this far\n");
mxFree(docname);
x=0;
return;
}
Thanks in advance for your help

답변 (4개)

Jan
Jan 2014년 2월 14일
Where do your store the libxml2 libraries?
How does your command for the mexing look like? Did you specify the library?
  댓글 수: 1
Kristopher
Kristopher 2014년 2월 18일
편집: Kristopher 2014년 2월 18일
In the command to compile the mex file I include the libxml2 libraries. I add the library directories using -L and the library files using -l. I also include the include directories using -I.
The compile line is
mex ('-g', include1, include2, include3,lib_dir1, lib_dir4,lib_dir6, mexFile, 'xmlParseFromMex.c', '-llibxml2', '-llibxml2_a', '-llibxml2_a_dll', '-liconv', '-liconv_a', '-lzdll', '-lzlib')
where
include1 = '-IC:\Users\Knilsen\Desktop\FOT Analysis Program\libxml2-2.7.8.win32\include'; and lib_dir1 = '-LC:\Users\Knilsen\Desktop\FOT Analysis Program\libxml2-2.7.8.win32\lib\';
etc

댓글을 달려면 로그인하십시오.


Kristopher
Kristopher 2014년 2월 19일
I am still unable to solve this problem, any help would be appreciated.

JEREMIE HABASQUE
JEREMIE HABASQUE 2014년 3월 3일
Hi,
I have the same problem with a specific mex file.
Invalid MEX-file 'C:\Program
Files\my_file.mexw64': Le
module spécifié est introuvable.
Thanks for any suggestion !
  댓글 수: 3
JEREMIE HABASQUE
JEREMIE HABASQUE 2014년 3월 5일
I'm not using libxml2 library. It's a personal mexfile. Here, the file is valid but not found even if the matlab path is correct !
Friedrich
Friedrich 2014년 3월 5일
Thats a complete different error. In your case a Module is missing => Missing DLL. For the actual initial problem a procedure is missing => Most likely wrong DLL is pulled which doesnt export the function the code is looking for.

댓글을 달려면 로그인하십시오.


Kristopher
Kristopher 2014년 3월 3일
I was never able to resolve this.
I ended up not using the libxml2 libraries and writing my own xml parsing functions in C.
  댓글 수: 1
Friedrich
Friedrich 2014년 3월 5일
You should do a dependency walker runtime profile of MATLAB.exe using the MEX file to see which procedure cannot be bound. That way you can determine the reason for the error. In the case you cannot read the DWI file feel free to attach it to a post and I will have a look.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by