Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Warning: non-mex version

Subject: Warning: non-mex version

From: Aprameya

Date: 5 Aug, 2008 21:29:01

Message: 1 of 7

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.

Subject: Warning: non-mex version

From: Ivan E. Cao-Berg

Date: 5 Aug, 2008 21:40:18

Message: 2 of 7

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

"Aprameya " <shanthisbe@yahoo.com> wrote in message
<g7agmt$d1a$1@fred.mathworks.com>...
> 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.

Subject: Warning: non-mex version

From: James Tursa

Date: 5 Aug, 2008 23:49:01

Message: 3 of 7

"Aprameya " <shanthisbe@yahoo.com> wrote in message
<g7agmt$d1a$1@fred.mathworks.com>...
> 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)

2) Type the following command:

>> 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).

3) Type the following command:

>> 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

Subject: Warning: non-mex version

From: Louay Fakhro

Date: 16 Mar, 2012 08:29:36

Message: 4 of 7

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.
-------------------------------------------------------------------------------------------------

"James Tursa" wrote in message <g7aotd$kj4$1@fred.mathworks.com>...
> "Aprameya " <shanthisbe@yahoo.com> wrote in message
> <g7agmt$d1a$1@fred.mathworks.com>...
> > 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)
>
> 2) Type the following command:
>
> >> 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).
>
> 3) Type the following command:
>
> >> 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
>

Subject: Warning: non-mex version

From: James Tursa

Date: 16 Mar, 2012 15:00:25

Message: 5 of 7

"Louay Fakhro" wrote in message <jjutlg$jef$1@newscl01ah.mathworks.com>...
> 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.

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

Subject: Warning: non-mex version

From: jaspreet

Date: 15 Jul, 2013 04:54:09

Message: 6 of 7

Hi James,
I am getting the same error as above and I tried out this :

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[])

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

Subject: Warning: non-mex version

From: James Tursa

Date: 15 Jul, 2013 06:48:10

Message: 7 of 7

"jaspreet " <jaspreet.chd.92@gmail.com> wrote in message <krvv9h$1dv$1@newscl01ah.mathworks.com>...
> Hi James,
> I am getting the same error as above and I tried out this :
>
> 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[])
>
> 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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us