Discussion:
Warning: non-mex version
(too old to reply)
Aprameya
2008-08-05 21:29:01 UTC
Permalink
Hello,
I am using dsexample1.m from R.Schreier's delta-sigma
toolbox. It gives me the following warning message

"Please compile the mex version with "mex simulateDSM.c"
Warning: You are running the non-mex version of
simulateDSM."

What command do I use to compile? I assume I can ignore the
warning but yet get right results? I am using Version
7.1.0.183 of MATLAB

Thank you.
Ivan E. Cao-Berg
2008-08-05 21:40:18 UTC
Permalink
The simple way to compile a mex file is to use the command

mex foo.c

If your system is happy it will output a mex-file. Depending
on the OS you are running you may to do some setup before
compiling, e.g. install a compiler or link Matlab to the
appropriate compiler. Try compiling, if it works, congrats!

Ivan
Post by Aprameya
Hello,
I am using dsexample1.m from R.Schreier's delta-sigma
toolbox. It gives me the following warning message
"Please compile the mex version with "mex simulateDSM.c"
Warning: You are running the non-mex version of
simulateDSM."
What command do I use to compile? I assume I can ignore the
warning but yet get right results? I am using Version
7.1.0.183 of MATLAB
Thank you.
James Tursa
2008-08-05 23:49:01 UTC
Permalink
Post by Aprameya
Hello,
I am using dsexample1.m from R.Schreier's delta-sigma
toolbox. It gives me the following warning message
"Please compile the mex version with "mex simulateDSM.c"
Warning: You are running the non-mex version of
simulateDSM."
What command do I use to compile? I assume I can ignore the
warning but yet get right results? I am using Version
7.1.0.183 of MATLAB
Thank you.
1) Set the default directory to the location where the
simulateDSM.c file is. This needs to be on the MATLAB path,
btw. (e.g., you can use the Current Directory pane)
Post by Aprameya
mex -setup
Press Enter when it asks if you want MATLAB to search for
compilers, then enter the number associated with lcc, the
built-in C compiler (or you could pick any other C compiler
from the list).
Post by Aprameya
mex simulateDSM.c
This will probably leave you with three files in that directory:

simulateDSM.c
simulateDSM.mexw32 (or some other system dependent suffix)
simulateDSM.m

When you call the simulateDSM function, MATLAB will pick the
simulateDSM.mexw32 instead of the simulateDSM.m if they are
both present. What is currently happening in your case is
that simulateDSM.mexw32 is not present, so it runs the
m-file. Once you compile the c source code, however, MATLAB
will be running the mex file instead since mex files take
precedence over m-files. The m-file is still used whenever
you use "lookfor" or "help simulateDSM", so don't delete the
m-file.

James Tursa
Louay Fakhro
2012-03-16 08:29:36 UTC
Permalink
Hi James, Please help me with this.

i did what you said by selecting the compiler and that part went well however after i use the mex command i get the following errors:
Could you please help me?

--------------------------------------------------------------------------
simulateDSM.c(141) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(142) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(147) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(155) : warning C4090: 'function' : different 'const' qualifiers
simulateDSM.c(158) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(170) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(178) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(183) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(363) : error C2371: 'mexFunction' : redefinition; different basic types
C:\Program Files\MATLAB\R2011a\extern\include\mex.h(145) : see declaration of 'mexFunction'

C:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Compile of 'simulateDSM.c' failed.
-------------------------------------------------------------------------------------------------
Post by James Tursa
Post by Aprameya
Hello,
I am using dsexample1.m from R.Schreier's delta-sigma
toolbox. It gives me the following warning message
"Please compile the mex version with "mex simulateDSM.c"
Warning: You are running the non-mex version of
simulateDSM."
What command do I use to compile? I assume I can ignore the
warning but yet get right results? I am using Version
7.1.0.183 of MATLAB
Thank you.
1) Set the default directory to the location where the
simulateDSM.c file is. This needs to be on the MATLAB path,
btw. (e.g., you can use the Current Directory pane)
Post by Aprameya
mex -setup
Press Enter when it asks if you want MATLAB to search for
compilers, then enter the number associated with lcc, the
built-in C compiler (or you could pick any other C compiler
from the list).
Post by Aprameya
mex simulateDSM.c
simulateDSM.c
simulateDSM.mexw32 (or some other system dependent suffix)
simulateDSM.m
When you call the simulateDSM function, MATLAB will pick the
simulateDSM.mexw32 instead of the simulateDSM.m if they are
both present. What is currently happening in your case is
that simulateDSM.mexw32 is not present, so it runs the
m-file. Once you compile the c source code, however, MATLAB
will be running the mex file instead since mex files take
precedence over m-files. The m-file is still used whenever
you use "lookfor" or "help simulateDSM", so don't delete the
m-file.
James Tursa
James Tursa
2012-03-16 15:00:25 UTC
Permalink
Post by Louay Fakhro
Hi James, Please help me with this.
Could you please help me?
--------------------------------------------------------------------------
simulateDSM.c(141) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(142) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(147) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(155) : warning C4090: 'function' : different 'const' qualifiers
simulateDSM.c(158) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(170) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(178) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(183) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
simulateDSM.c(363) : error C2371: 'mexFunction' : redefinition; different basic types
C:\Program Files\MATLAB\R2011a\extern\include\mex.h(145) : see declaration of 'mexFunction'
C:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Compile of 'simulateDSM.c' failed.
The fact that you are getting possible loss of data warnings when converting from size_t to int indicates that size_t is longer than an int ... i.e. size_t is 64 bits and an int is 32-bits. So you are likely on a 64-bit system. My guess is that you probably don't need a 64-bit integer for the calculations (otherwise the 32-bit code wouldn't work), so you can *probably* ignore those warnings. The reason I say probably is because I haven't looked at the code in any detail to see if it is just a precision issue or if there is some other issue.

The error is with this line:

void mexFunction(int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs)

I would change it to this instead:

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

Note that I have reduced the number of * from two to one, and added square brackets. That will match the definition in the mex.h file and should eliminate the error.

James Tursa
jaspreet
2013-07-15 04:54:09 UTC
Permalink
Hi James,
Post by James Tursa
void mexFunction(int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
However, I am still getting the same error. Do I need to make any other changes too?

Also when I type
mex ai2mif.c I get an error that the strings.h file can't be found. Any suggestions?

Can you please help me out as this is very urgent. I need to submit my project

Thanks,
Jaspreet
James Tursa
2013-07-15 06:48:10 UTC
Permalink
Post by Louay Fakhro
Hi James,
Post by James Tursa
void mexFunction(int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
However, I am still getting the same error. Do I need to make any other changes too?
Also when I type
mex ai2mif.c I get an error that the strings.h file can't be found. Any suggestions?
Can you please help me out as this is very urgent. I need to submit my project
Thanks,
Jaspreet
Can you post the exact errors you are getting? Is it possible you need string.h instead of strings.h?

James Tursa
JTM
2015-04-21 11:02:05 UTC
Permalink
Post by James Tursa
Post by Louay Fakhro
Hi James,
Post by James Tursa
void mexFunction(int nlhs, mxArray **plhs, int nrhs, const mxArray **prhs)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
However, I am still getting the same error. Do I need to make any other changes too?
Also when I type
mex ai2mif.c I get an error that the strings.h file can't be found. Any suggestions?
Can you please help me out as this is very urgent. I need to submit my project
Thanks,
Jaspreet
Can you post the exact errors you are getting? Is it possible you need string.h instead of strings.h?
James Tursa
For some reason the "__STDC__" variable is not defined. Adding
#define __STDC__
somewhere in the beginning of the file should do the trick. There is probably another more proper way of doing this, but it works. The warnings you see appears to be due to wrong interpretation of the "nlhs, plhs, nrhs, prhs" arguments, and should go away as well.

BR
Jan-Tore

Continue reading on narkive:
Loading...