invalid mex-file specified procedure could not be found

30 views (last 30 days)
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

Answers (4)

Jan
Jan on 14 Feb 2014
Where do your store the libxml2 libraries?
How does your command for the mexing look like? Did you specify the library?
  1 Comment
Kristopher
Kristopher on 18 Feb 2014
Edited: Kristopher on 18 Feb 2014
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

Sign in to comment.


Kristopher
Kristopher on 19 Feb 2014
I am still unable to solve this problem, any help would be appreciated.

JEREMIE HABASQUE
JEREMIE HABASQUE on 3 Mar 2014
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 Comments
JEREMIE HABASQUE
JEREMIE HABASQUE on 5 Mar 2014
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 on 5 Mar 2014
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.

Sign in to comment.


Kristopher
Kristopher on 3 Mar 2014
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 Comment
Friedrich
Friedrich on 5 Mar 2014
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.

Sign in to comment.

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!