Why do I get these error messages when using "MexMe"?

I'd like to use MexMe to create mex-files automatically. But each time I run TestMexMe.m, it gives me a host of error messages (20-30) concerning the file mydouble.c.
These are a few of the error messages I get using the Lcc compiler:
>> TestMexMe
Error mydouble.c: 33 illegal statement termination
Error mydouble.c: 33 skipping `const'
Error mydouble.c: 33 illegal use of type name `mxArray'
Error mydouble.c: 33 undeclared identifier `x_ptr'
Error mydouble.c: 33 operands of * have illegal types `incomplete struct mxArray_tag defined at C:\PROGRA~1\MATLAB\R2011B\extern\include\matrix.h 299' and `int'
...etc...
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Compile of 'mydouble.c' failed.
Error using mex (line 206)
Unable to complete successfully.
Error in TestMexMe (line 25)
mex mydouble.c
Using MS Visual C++ compiler I get similar errors (all of them have to do with mmydouble.c).
Any idea what might be causing these issues?
ps.: I'm using the R 2011 b version on WinXP.

2 comentarios

Jan
Jan el 30 de Oct. de 2012
What did the author of this tool reply to your email?
dave
dave el 30 de Oct. de 2012
Unfortunately he hasn't replied yet..

Iniciar sesión para comentar.

Respuestas (3)

Jan
Jan el 30 de Oct. de 2012
Editada: Jan el 30 de Oct. de 2012

0 votos

These are obvioulsy errors in the mydouble.c program and not caused by MexMe. When you post teh source of this function, we could find the problem. What do you find in line 33?

14 comentarios

I don't only get error messages for line 33 but also for others, so here are lines 33-53 of mydouble.c:
const mxArray *x_ptr = prhs[0];
mexmetypecheck(x_ptr,mxDOUBLE_CLASS,"Argument x (#1) is expected to be of type double");
const mwSize x_m = mxGetM(x_ptr);
const mwSize x_n = mxGetN(x_ptr);
const mwSize x_length = x_m == 1 ? x_n : x_m;
const mwSize x_numel = mxGetNumberOfElements(x_ptr);
const int x_ndims = mxGetNumberOfDimensions(x_ptr);
const mwSize *x_size = mxGetDimensions(x_ptr);
const double *x = (double *) mxGetData(x_ptr);
mwSize y_dims[] = {x_m, x_n};
plhs[0] = mxCreateNumericArray(2,y_dims,mxDOUBLE_CLASS,mxREAL);
mxArray **y_ptr = &plhs[0];
double *y = (double *) mxGetData(*y_ptr);
for(mwSize i = 0; i < x_numel; i++) {
y[i] = x[i]*x[i];
And corresponding to the above code, this is the entire error message I get:
>> TestMexMe
mydouble.c
mydouble.c(33) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(34) : error C2065: 'x_ptr': nichtdeklarierter Bezeichner
mydouble.c(34) : warning C4047: 'Funktion': Anzahl der Dereferenzierungen bei 'const mxArray *' und 'int' unterschiedlich
mydouble.c(34) : warning C4024: 'mexmetypecheck': Unterschiedliche Typen fr formalen und bergebenen Parameter 1
mydouble.c(35) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(36) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(37) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(38) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(39) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(40) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(41) : error C2143: Syntaxfehler: Es fehlt ';' vor 'const'
mydouble.c(44) : error C2275: 'mwSize': Ungltige Verwendung dieses Typs als Ausdruck
C:\PROGRA~1\MATLAB\R2011B\extern\include\tmwtypes.h(792): Siehe Deklaration von 'mwSize'
mydouble.c(44) : error C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'y_dims'
mydouble.c(44) : error C2065: 'y_dims': nichtdeklarierter Bezeichner
mydouble.c(44) : error C2059: Syntaxfehler: ']'
mydouble.c(45) : error C2065: 'y_dims': nichtdeklarierter Bezeichner
mydouble.c(45) : warning C4047: 'Funktion': Anzahl der Dereferenzierungen bei 'const int *' und 'int' unterschiedlich
mydouble.c(45) : warning C4024: 'mxCreateNumericArray_700': Unterschiedliche Typen fr formalen und bergebenen Parameter 2
mydouble.c(46) : error C2275: 'mxArray': Ungltige Verwendung dieses Typs als Ausdruck
c:\programme\matlab\r2011b\extern\include\matrix.h(299): Siehe Deklaration von 'mxArray'
mydouble.c(46) : error C2065: 'y_ptr': nichtdeklarierter Bezeichner
mydouble.c(46) : error C2100: Ungltige Dereferenzierung.
mydouble.c(47) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
mydouble.c(52) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
mydouble.c(52) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
mydouble.c(52) : error C2143: Syntaxfehler: Es fehlt ')' vor 'Typ'
mydouble.c(52) : error C2143: Syntaxfehler: Es fehlt ';' vor 'Typ'
mydouble.c(52) : error C2065: 'i': nichtdeklarierter Bezeichner
mydouble.c(52) : error C2065: 'x_numel': nichtdeklarierter Bezeichner
mydouble.c(52) : warning C4552: '<': Operator hat keine Auswirkungen; Operator mit Nebeneffekt erwartet
mydouble.c(52) : error C2065: 'i': nichtdeklarierter Bezeichner
mydouble.c(52) : error C2059: Syntaxfehler: ')'
mydouble.c(52) : error C2143: Syntaxfehler: Es fehlt ';' vor '{'
mydouble.c(53) : error C2065: 'y': nichtdeklarierter Bezeichner
mydouble.c(53) : error C2065: 'i': nichtdeklarierter Bezeichner
mydouble.c(53) : error C2109: Index erfordert ein Array oder einen Zeigertyp
mydouble.c(53) : error C2065: 'x': nichtdeklarierter Bezeichner
mydouble.c(53) : error C2065: 'i': nichtdeklarierter Bezeichner
mydouble.c(53) : error C2109: Index erfordert ein Array oder einen Zeigertyp
mydouble.c(53) : error C2065: 'x': nichtdeklarierter Bezeichner
mydouble.c(53) : error C2065: 'i': nichtdeklarierter Bezeichner
mydouble.c(53) : error C2109: Index erfordert ein Array oder einen Zeigertyp
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Compile of 'mydouble.c' failed.
Error using mex (line 206)
Unable to complete successfully.
Error in TestMexMe (line 25)
mex mydouble.c end
btw: sorry for the german error statements - how can they be changed to english?
José-Luis
José-Luis el 30 de Oct. de 2012
Editada: José-Luis el 30 de Oct. de 2012
What are your #includes?. You might be missing some.
#include <mex.h>
#include <math.h>
#include <matrix.h>
#include <stdlib.h>
#include <float.h>
#include <string.h>
José-Luis
José-Luis el 30 de Oct. de 2012
I think #include mat.h is missing.
Jan
Jan el 30 de Oct. de 2012
@Jose: mat.h is included by mex.h. Anyhow, I do noth think that the problem is related to a missing MAT-file access.
José-Luis
José-Luis el 30 de Oct. de 2012
My bad.
dave
dave el 30 de Oct. de 2012
I added #include mat.h, but mexing the file still causes the errors...
Jan
Jan el 30 de Oct. de 2012
Editada: Jan el 30 de Oct. de 2012
@Mike: When the C-compiler is confused in line 33, the following lines will increase the confusion. Therefore care for the first error at first and see if the others vanish automatically. On the other hand: The line 32 might contain the problem already: "Es fehlt ';' vor 'const'" seems like the line before 33 is not terminated (translation: missing ";" before const).
You can create English error messages, when you install the English version of the compiler. But fortunately some people are talking German in this forum, although Oleg thought it is Dutch. (I never forget such details, Oleg :-) )
dave
dave el 30 de Oct. de 2012
Editada: dave el 30 de Oct. de 2012
Thanks Jan and José-Luis for your support so far, but unfortunately I can't get it to work...
Jan
Jan el 30 de Oct. de 2012
Editada: Jan el 30 de Oct. de 2012
I'm getting nervous. As soon as you show us the preceeding lines of the created C-files, we had a chance to find the problem. The bunch of follwoing error messages is really useless and meaningless. Therefore we currently have a signal to noise ratio in this thread of about 2 lines to 400 lines.
Please, Mike, post what you find in line 32 of the created programs and concentrate on the first compiler error only. Perhaps MexMe creates C++ source and LCC is a C-compiler only, while GCC can handle both.
dave
dave el 30 de Oct. de 2012
Editada: dave el 30 de Oct. de 2012
Line 32 is empty ...
And these are lines 30 and 31:
if(nlhs != 1 || nrhs != 1)
mexErrMsgTxt("Function must be called with 1 arguments and has 1 return values");
Jan
Jan el 31 de Oct. de 2012
Editada: Jan el 31 de Oct. de 2012
Is the line break caused by the formatting in the forum?
Anyhow, I give up. I'm going to install MexMe on my own computer, such that I can get the required information to find the problem.
dave
dave el 1 de Nov. de 2012
In the file mydouble.c there's no line break between the words "return" and "values". I'm sorry that I'm causing so much trouble with this problem, but that's (at least partially) due to the fact that I'm still pretty new to Matlab and its components.
Anyway...thank you very much for taking a look at it, Jan ;)
Jan
Jan el 12 de Nov. de 2012
See my comments at FEX: MexMe. The automatically created code has C++ style, but the Windows compiler assumes C according to the file extension. Either rename the file to .cpp (e.g. by modifying MexMe.m), or resort the lines such that the declarations of variables are move before the first line of calculations.
I do not think that MexMe can create Mex-files "in no time" as advertised, but it is much faster than even a very experienced C-Mex-programmer. It must be expected, that automatically generated code demands for a manual fine tuning.

Iniciar sesión para comentar.

dave
dave el 31 de Oct. de 2012
Editada: dave el 31 de Oct. de 2012

0 votos

I spent a couple of hours today searching through C/C++ forums for the solution to the error message I get in line 33 - without any real success. Additionally I installed open watcom c/c++ compiler, to see if mexing the file works with this one - it doesn't.
Couldn't it be that working with MexMe just doesn't work for me because I use Windows??
In MexMes's "comments and rating" section there is actually a quote of another MexMe user saying something about using MexMe on Windows:
"Awesome! Worked as expected for me in my usual Linux environment. Tried to share with a coworker on Windows who couldn't get the c file mexed. I am not as familiar with the Visual Studio compiler, so I haven't been able to figure it out (we have both successfully mexed files in the past)."

2 comentarios

Jan
Jan el 31 de Oct. de 2012
You have successfully installed OpenWatcom under R2011b?! How did you do this?
dave
dave el 1 de Nov. de 2012
There was nothing special about the installation - I just downloaded the file open-watcom-c-win32-1.9.exe from here, installed it, ran mex -setup in Matlab and selected the Open WATCOM C++ compiler.

Iniciar sesión para comentar.

dave
dave el 6 de Nov. de 2012

0 votos

Jan, do you get the same errors/problems when running Mexme?

1 comentario

Jan
Jan el 12 de Nov. de 2012
Yes. Errors, problems and solutions. See my comment above.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Compiler en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Oct. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by