MATLAB: Mbuild setup fails / crashes, while mex setup works / succeeds / passes in 2017a windows 7

2017aMATLABMATLAB Compilermbuildmexmingw

Howdy, Trying to make an s-function outside of matlab, and the mingw make utility is citing "undefined reference : mxGetPr" in simulink files as an example. So I'm trying to make sure i have all the includes and libs, and options setup for the make to work. After a few hours of research the mbuild script was brought to my attention. Looking at its xml for make file options, it looks like what i need. But long story short i was attempting to use mbuild but the -setup switch keeps failing. Even though a supported compiler is found… by mex!
>> mbuild -setup Error using mbuild (line 164) Unable to complete successfully. No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler. For more options, visit http://www.mathworks.com/support/compilers/R2017a/.
>> getenv('MINGWROOT')
ans =
'C:\MinGW\'
>> 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: http://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
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: http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
>> getenv('MW_MINGW64_LOC')
ans =
'C:\MinGW\'

Best Answer

The error message 'You can install the freely available MinGW-w64 C/C++ compiler...' is misleading. As of R2015b, the free compiler supported for deployment is Windows SDK 7.1. MinGW is supported only with MEX. Please install the Windows SDK 7.1 if you would like to use mbuild.
Related Question