"Matlab R2016a running'mex -setup', wrong use of mex can not find a supported compiler or SDK" solution

The original intentions written here are the first is the memo, the second is the hope to get advice from an expert, and the third is the hope that you can meet like-minded friends.

Problem Description:

A .c file needs to be executed and compiled by Matlab R2016a to execute the subsequent .m file command line window:
>> mex -setup
错误使用 mex
未找到支持的编译器或 SDK。您可以安装免费提供的 MinGW-w64 C/C++ 编译器;请参阅安装 MinGW-w64 编译器。有关更多选项,请访
问 http://www.mathworks.com/support/compilers/R2016a/win64.html。

Insert picture description here


Cause Analysis:

Not installed in Matlab R2016a softwareMinGW-w64 C/C++ compiler


solution:

Baidu results:
specific solutions:
Insert picture description here

Matlab R2016a needs to be installed correctly
mingw-w64-install.exe
tdm64-gcc-4.9.2.exe

1. Failure experience

Reference: Matlab R2016a gcc 4.9.2 installation

Find the relevant software installation method to install and findinstallation failed:
(The root cause may be due to the problem of version update) The
specific problems are as follows:
1. To install the mingw-w64 software, you need to select the version: 4.9.2; (select the default location to install) the
Insert picture description here
Insert picture description here
Insert picture description here
result is an installation error
2. Install tdm64-gcc-4.9.2 , Click Creat , prompt, need to download the latest version .
Insert picture description here

2. Success method

Prompt to download the latest version, then let's install the latest version!

Reference: How to configure MinGW-w64 C/C++ compiler in Matlab 2016a

(1) Download MinGW-w64 C/C++ compiler

Download the tdm64-gcc-9.2.0.exe installation package
Insert picture description here
Insert picture description here

(2) Install MinGW-w64 C/C++ compiler

Note: Install according to the default path
If it is installed on other disks, when adding the path, " D:\TDM-GCC-64" is not an internal or external command, nor is it an executable program"
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

(3) Set as system environment variable

Right-click the computer and select Properties-Advanced System Settings-Advanced-Environment Variables, select "New" under System Variables :
Variable name:MW_MINGW64_LOC
variable:C:\TDM-GCC-64
Type the variable value in the location where the MinGW-w64 compiler is installed. The default installation is "C:\TDM-GCC-64" (Note: "C:\TDM-GCC-64" is the installation directory of MinGW)
Insert picture description here

(4) Use MATLAB to set MW_MINGW64 as a temporary environment variable

Run the following command in the MATLAB command window:

>> setenv('MW_MINGW64_LOC','C:\TDM-GCC-64') 

"C:\TDM-GCC-64" is the installation directory of MinGW. In this method, you need to run this command every time you start MATLAB for MATLAB to use MinGW correctly. Order to your "startup.m"File. This command is executed every time MATLAB starts.
Insert picture description here

How to setstartup.mFiles to achieve perfect operation"mex-setup"
Please refer to the next blog post How to run "mex-setup" perfectly in
Matlab R2016a

references

1. How to configure MinGW-w64 C/C++ compiler in Matlab 2016a
2. Matlab installs the free MinGW-w64 C/C++ compiler
3. How to install MinGW-w64 C/C++ compiler in MATLAB
4. Matlab2016a The compiler cannot be found using Mex to install the corresponding MinGW-w64
5. The mex -setup command is incorrect. The problem of using mex [MATLAB installs the MinGW-w64 compiler]
6. Completely solve the problem that the mex-setup in Matlab does not find a supported compiler or SDK
7. How to configure MinGW-w64 C/C++ compiler in Matlab2018a
8. How to configure MinGW-w64 C/C++ compiler in Matlab2018a
9. Matlab R2016a gcc 4.9.2 installation

Guess you like

Origin blog.csdn.net/weixin_45656790/article/details/109090575