Error using mex : In function 'void mexFunction(int, mxArray**, int, const mxArray**)'

3 次查看(过去 30 天)
In my mecherMex.cpp, I wright down "void mexFunction (int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) {", but I dont know why system says my function is 'void mexFunction(int, mxArray**, int, const mxArray**)'. Does any one has same problem?

回答(1 个)

James Tursa
James Tursa 2020-6-8
编辑:James Tursa 2020-6-8
The error is not with mexFunction. The error is with line in your source code:
const int32_t *dims1 = mxGetDimensions(prhs[1]);
which needs to be this instead:
const mwSize *dims1 = mxGetDimensions(prhs[1]);
To answer your question as to why you write this signature:
void mexFunction (int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
but the compiler says the signature is this:
void mexFunction(int, mxArray**, int, const mxArray**)
you have to remember that C/C++ does not pass arrays in argument lists. The square brackets [ ] that look like arrays are in fact interpreted by the compiler as "pointer to" when they appear in argument lists. So this
mxArray *plhs[ ]
in an argument list does not mean "array of pointers to mxArray"
It does mean "pointer to pointer to mxArray", i.e. the [ ] simply gets replaced with "pointer to".
  2 个评论
CHENGXIAN KI
CHENGXIAN KI 2020-6-10
thanks for ur answer,
I try to instead like u said
but still lots of error
I dont get it
actually I never learned this before
i just want to try data from this web :http://www.cvlibs.net/software/libviso/
so I downloaded the dataset and the code as u saw
in the ReadMe.txt. it says that just run the make.m
and I can see demo.
but I dont know why this make so much trubles
thank you for your answer again
James Tursa
James Tursa 2020-6-10
Looks to me like you still have mwSize vs int32_t mismatches in your code. You need to fix those up.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by