CaptainProg
CaptainProg

Reputation: 5690

C++ MEX compilation in MATLAB

I am trying to use a function called edfImport (available here: http://kobi.nat.uni-magdeburg.de/edfImport)

In order to use the function, I must first run edfCompile (included in the toolkit). When running edfCompile, I get an error:

??? Error using ==> mex
Unable to complete successfully

I am running MATLAB 7.1 (R14) and have the latest version of MinGW, Cygwin and Gnumex setup for my compiler (according to the instructions on this page: http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII4.0/cygwin.htm)

I am able to compile example mex files, but I'm still not convinced that this isn't an issue with the way my compiler is setup. Any tips gratefully received. It would be nice to know if anyone else has trouble running edfCompile as well... (http://kobi.nat.uni-magdeburg.de/edfImport)

Many thanks

Edit: The error message in full:

In file included from edfMexImport.cpp:6:0: 
EDFFile2.h:37:39: error: 'mwSize' has not been declared 
EDFFile2.h:127:45: error: 'mwIndex' has not been declared 
edfMexImport.cpp: In function 'void mexFunction(int, mxArray**, int, const mxArray**)': 
edfMexImport.cpp:12:3: error: 'mwSize' was not declared in this scope 
edfMexImport.cpp:12:10: error: expected ';' before 'OutputDims' 
edfMexImport.cpp:48:12: error: expected ';' before 'OptionsDimN' 
edfMexImport.cpp:49:9: error: 'OptionsDimN' was not declared in this scope 
edfMexImport.cpp:51:13: error: 'OptionsDim' was not declared in this scope 
edfMexImport.cpp:51:33: error: expected primary-expression before ')' token 
edfMexImport.cpp:51:34: error: expected ';' before 'mxGetDimensions' 
edfMexImport.cpp:73:12: error: expected ';' before 'FlagsDimN' 
edfMexImport.cpp:74:9: error: 'FlagsDimN' was not declared in this scope 
edfMexImport.cpp:76:13: error: 'FlagsDim' was not declared in this scope 
edfMexImport.cpp:76:31: error: expected primary-expression before ')' token 
edfMexImport.cpp:76:32: error: expected ';' before 'mxGetDimensions' 

C:\PROGRAM FILES\MATLAB71\BIN\MEX.PL: Error: Compile of 'edfMexImport.cpp' failed. 

??? Error using ==> mex
Unable to complete successfully

Error in ==> edfCompile at 15
eval(sprintf('mex -I''%s'' edfMexImport.cpp EDFFILE2.cpp ''%s/edfapi.lib''', edfapiIncludesFolder, edfapiLibraryFolder));

Upvotes: 1

Views: 2207

Answers (3)

Peter
Peter

Reputation: 14937

The MEX file has been modified to support the 64-bit "large array handling API", as described in this document:

http://www.mathworks.com/support/solutions/en/data/1-5C27B9/

Note that this optional large variable support was first added in R7.3 (2006b), and your version is even older. Basically, your MATLAB is too old for the API used by the MEX file. That said, if the MEX file is simple enough, Gunther's solution might be the simple answer to "backport" the MEX file to your older MATLAB. Functions like mxGetDimensions() now return mwSize*, but used to return int*.

So upgrade MATLAB if you can, else try Gunther's answer and let us know how it goes.

Upvotes: 1

Gunther Struyf
Gunther Struyf

Reputation: 11168

It looks like some type definitions are missing, particularly the mwSize and mwIndex type. Can you add the following to EDFFile2.h and try again?

just below

#include "edf.h"
#include <mex.h>

add this:

#ifndef mwSize
    #define mwSize int
#endif

#ifndef mwIndex
    #define mwIndex int
#endif

Upvotes: 2

Terenty Rezman
Terenty Rezman

Reputation: 1

Have you looked inside edfCompile.m? Unfortunatlly I don't have Matlab installed on my PC, so I can only suggest you to try to compile the two .cpp files edfMexImport.cpp and EDFFILE2.cpp manually with edfapi.lib

Upvotes: 0

Related Questions