Why minGW not work as expected?

5 ビュー (過去 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.

  1 件のコメント
samar mahmoud
samar mahmoud 2018 年 4 月 23 日
Thanks Jan!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by