Why minGW not work as expected?

조회 수: 12 (최근 30일)
samar mahmoud
samar mahmoud 2018년 4월 16일
댓글: Jonas Svedberg 2018년 4월 25일
I download minGW form https://github.com/mathworks/MinGW_53 and configure it with matlab the output of mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. You will be required
to update your code to utilize the new API.
You can find more information about this at:
https://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
if true
% code
end
But when I test it at a previous code(.cpp) which is correctly compiled I received the error
In function 'void mexFunction(int, mxArray**,
int, const mxArray**)':
C:\Users\User\Desktop\t\private\edgesDetectMex.cpp:99:63: error: cannot convert 'const int*' to
'const mwSize* {aka const long long unsigned int*}' for argument '2' to 'mxArray*
mxCreateNumericArray_730(mwSize, const mwSize*, mxClassID, mxComplexity)'
pl[0] = mxCreateNumericArray(3,outDims,mxSINGLE_CLASS,mxREAL);
If I correctly configured minGW or not? and if not what is the wrong?
  댓글 수: 2
samar mahmoud
samar mahmoud 2018년 4월 16일
when run configuremingw the output
Undefined variable "mex_spkg" or class "mex_spkg.getEnvVarName".
Error in configuremingw
Jonas Svedberg
Jonas Svedberg 2018년 4월 25일
Same happens to me " Undefined variable "mex_spkg" or class "mex_spkg.getEnvVarName".
Error in configuremingw"
Using 2017b

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2018년 4월 16일
편집: Jan 2018년 4월 16일

The error message is clear: The 2nd argument of mxCreateNumericArray is expected to be a mwSize*, but it is a int* in your code. So adjust the type of outDims accordingly.

The code might work correctly with another compiler, but remember, that the definition of int depends on the platform and the compiler. Therefore the Mex interface uses e.g. mwSize for many years now and should be used to avoid such incompatibilities.

 Why minGW not work as expected?

It seems like MinGW works as expected. This is just a bug in the code.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by