invalid mex-file specified procedure could not be found

25 ビュー (過去 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 Center および File ExchangeWrite 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