Why minGW not work as expected?

5 visualizzazioni (ultimi 30 giorni)
samar mahmoud
samar mahmoud il 16 Apr 2018
Commentato: Jonas Svedberg il 25 Apr 2018
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 Commenti
samar mahmoud
samar mahmoud il 16 Apr 2018
when run configuremingw the output
Undefined variable "mex_spkg" or class "mex_spkg.getEnvVarName".
Error in configuremingw
Jonas Svedberg
Jonas Svedberg il 25 Apr 2018
Same happens to me " Undefined variable "mex_spkg" or class "mex_spkg.getEnvVarName".
Error in configuremingw"
Using 2017b

Accedi per commentare.

Risposta accettata

Jan
Jan il 16 Apr 2018
Modificato: Jan il 16 Apr 2018

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.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by