Why is MinGW compiler not recognized anymore after restarting MATLAB or rebooting my PC in R2021a and earlier?

74 ビュー (過去 30 日間)
After installing the "MATLAB Support for MinGW-w64 C/C++ Compiler" support package in MATLAB, the command "mex -setup" reports that the compiler is correctly installed:
>> mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
However, after I restart MATLAB or reboot my PC, the same command does not detect the MinGW compiler as installed anymore:
>> mex -setup
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, see 
http://www.mathworks.com/support/compilers/R2015b/win64.html.
Why does MATLAB not detect the MinGW compiler anymore after a restart of MATLAB or a PC reboot?

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 8 月 9 日
編集済み: MathWorks Support Team 2023 年 8 月 9 日

What This Issue Means

In R2021a and earlier releases, when installing the MinGW compiler, the system environment variable MW_MINGW64_LOC is set with the path to the MinGW installation folder. In some organizations, there may be policies in place that reset or delete environment variables. If this environment variable is not staying set following the installation, or after restarting MATLAB or rebooting your PC, the behavior described above may occur.
Running the following command in MATLAB:
>> getenv('MW_MINGW64_LOC')
ans =
  0×0 empty char array
will confirm that the environment variable is not set.
NOTE: In R2021b and later, the behavior of the "MATLAB Support for MinGW-w64 C/C++ Compiler" support package changed so that it no longer creates a permanent MW_MINGW64_LOC system environment variable. Instead, the environment variable is set for every MATLAB session which does not require administrator privileges.
 

Try this workaround - For R2021a and earlier release

The solution is to have an administrator set the environment variable on your system. Your local IT administrator should be able to help with this. On Windows 10, you can find this panel by entering "Edit the system environment variables" in the Windows search:
The environment variable should have the following name and value:
  • Variable Name: MW_MINGW64_LOC
  • Variable Value: <SupportPackageRoot>\3P.instrset\mingw_w64.instrset or <SupportPackageRoot>\MW_MinGW_x_x for older versions of MATLAB
where <SupportPackage Root> is the output received for the command:
>> matlabshared.supportpkg.getSupportPackageRoot
Now, running the 'getenv' command in MATLAB should return the desired value, and you should be able to select MinGW64 compiler using 'mex -setup':
>> getenv('MW_MINGW64_LOC')
ans =
  'C:\ProgramData\MATLAB\SupportPackages\R2021a\3P.instrset\mingw_w64.instrset'
>> mex -setup
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
Note that the release number shown above may differ if you're not using R2021a.

その他の回答 (0 件)

タグ

タグが未入力です。

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by