I already have MinGW on my computer. How do I configure it to work with MATLAB?
Mostra commenti meno recenti
I already have MinGW on my computer. How do I configure it to work with MATLAB?
Risposta accettata
Più risposte (3)
Paul Wintz
il 16 Ago 2021
Spostato: Stefanie Schwarz
il 10 Ago 2023
6 voti
The instruction the description of MINGWROOT as the "MinGW installation directory containing the MinGW compiler binaries" is confusing. I thought, initally, that the path would include the bin folder (after all, that is where the binaries are located). To the contrary, however, MINGWROOT should point to the parent directory of bin.
So I needed to set MINGWROOTC to \mingw\mingw64 not C:\mingw\mingw64\bin.
1 Commento
Stefanie Schwarz
il 10 Ago 2023
I agree, thank you very much for this feedback! We will revise the text above to make this clearer.
Zhibin Deng
il 15 Mag 2023
Spostato: Stefanie Schwarz
il 10 Ago 2023
3 voti
I got an error
"Error using configuremingw
Unable to setup the MinGW compiler due to administrator privileges not granted."
My matlab version is 2023a under Windows 11. I have run matlab using in the administrative mode.
How to solve this issue?
1 Commento
Zhibin Deng
il 15 Mag 2023
Spostato: Stefanie Schwarz
il 10 Ago 2023
Richard Crozier
il 20 Gen 2020
Spostato: Stefanie Schwarz
il 10 Ago 2023
I am trying the described solution in Matlab R2018a. If I run without administrator priviliges I get the following when trying to run configuremingw
>> configuremingw
Error using configuremingw
Unable to setup the MinGW compiler due to administrator privileges not granted
I then tried manually changing MW_MINGW64_LOC but without success, see the below matlab session:
>> mex -setup C++
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.
>> getenv ('MW_MINGW64_LOC')
ans =
'C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset'
>> mingwdir = getenv ('MW_MINGW64_LOC')
mingwdir =
'C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset'
>> ls (mingwdir)
. build-info.txt lib opt
.. etc libexec share
bin include licenses x86_64-w64-mingw32
>> ls ('C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64')
. build-info.txt lib opt
.. etc libexec share
bin include licenses x86_64-w64-mingw32
>> setenv ('MW_MINGW64_LOC', 'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64')
>> getenv ('MW_MINGW64_LOC')
ans =
'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64'
>> 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
>> mex -setup C++
Error using mex
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler.
For more options, visit https://www.mathworks.com/support/compilers.
>> mex -setup FORTRAN
Error using mex
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
>> CC = mex.getCompilerConfigurations
CC =
2×1 CompilerConfiguration array with properties:
Name
Manufacturer
Language
Version
Location
ShortName
Priority
Details
LinkerName
LinkerVersion
MexOpt
>> CC(1)
ans =
CompilerConfiguration with properties:
Name: 'MinGW64 Compiler (C++)'
Manufacturer: 'GNU'
Language: 'C++'
Version: '5.3.0'
Location: 'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64'
ShortName: 'mingw64-g++'
Priority: 'E'
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: 'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64\bin\g++'
LinkerVersion: ''
MexOpt: 'C:\Users\User\AppData\Roaming\MathWorks\MATLAB\R2018a\mex_C++_win64.xml'
>> CC(2)
ans =
CompilerConfiguration with properties:
Name: 'MinGW64 Compiler (C)'
Manufacturer: 'GNU'
Language: 'C'
Version: '5.3.0'
Location: 'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64'
ShortName: 'mingw64'
Priority: 'E'
Details: [1×1 mex.CompilerConfigurationDetails]
LinkerName: 'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64\bin\gcc'
LinkerVersion: ''
MexOpt: 'C:\Users\User\AppData\Roaming\MathWorks\MATLAB\R2018a\mex_C_win64.xml'
>> rnfoundry_setup
Setting up mexslmeval.
Warning: mexslmeval compilation failed, you may be missing required libraries, gsl and gslcblas
> In mexslmeval_setup (line 63)
In rnfoundry_setup (line 319)
Finished building mexslmeval.
Setting up mexMBCNodal and mexMBCNodalSharedMem.
Warning: Unable to compile mex function mexMBCNodal. Error reported was:
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler.
For more options, visit https://www.mathworks.com/support/compilers.
As you can see, merely changing the MW_MINGW64_LOC does not corectly modify the compiler configurations, at least when matlab is run as non-root.
I tried again, after starting matlab.exe using 'Run as administrator' as below:

If I do this, I get the exact same issue when tryiong to run configuremingw
>> configuremingw ('C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64')
Error using configuremingw
Unable to setup the MinGW compiler due to administrator privileges not granted.
setenv doesn't help either
>> setenv ('MW_MINGW64_LOC', 'C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64')
>> 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
>> mex -setup C++
Error using mex
No supported compiler was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler. For
more options, visit https://www.mathworks.com/support/compilers.
As others have noted, if configuremingw wasn't an obfuscated p file I could attempt to fix this. My suspicion is that configuremingw calls another system program or script which doesn't run with the same permissions.
Any suggestions for getting an alternative mingw to work on R2018a?
p.s. I also tried activating the administrator account, logging in as administrator and still get
>> configuremingw
Error using configuremingw
Unable to setup the MinGW compiler due to administrator privileges not granted.
1 Commento
Stefanie Schwarz
il 10 Ago 2023
Since you appear to have an existing installation of the MinGW Support Package, it is much easier if you just edit the system environment variable MW_MINGW64_LOC in the Windows settings (with the help of an admin) to have this value:
C:\Program Files\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64
Instead of:
C:\ProgramData\MATLAB\SupportPackages\R2018a\3P.instrset\mingw_w64.instrset
(which is where the MinGW compiler shipped with the support package resides).
Then, restart MATLAB.
Categorie
Scopri di più su Introduction to Installation and Licensing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!