How to install MinGW-w64 C/C++ compiler for use in

2019-07-26 14:00发布

问题:

I am installing the MinGW-w64 C/C++ compiler for use in MATLAB 20176b but there is several errors for that. How can install this compiler with all the necessary adjustments to use in Matlab 2016b?

As the first way directly from Matlab:

  1. Downloaded the MinGW-w64 C/C++ compiler for Windows from here: https://www.mathworks.com/matlabcentral/fileexchange/52848-matlab-support-for-mingw-w64-c-c++-compiler

  2. After running true Matlab and approval for installation and installing the packages, it gives an error as:

There was a problem installing the third-party software. To resolve this issue, contact Technical Support

The second approach is to install the MinGW-w64 C/C++ compiler separately and then adjust to use in Matlab. But After installation Matlab doesn't recognize it.

回答1:

The details provided on Matlab not recognizing the MinGW installation are a bit vague, but I'll take a shot at it.

When installing MinGW, the default installation directory is one with spaces in the path (Program Files). For some reason, this is not supported by Matlab (https://www.mathworks.com/help/matlab/matlab_external/compiling-c-mex-files-with-mingw.html):

Do not install MinGW in a location with spaces in the path name. For example, do not use: C:\Program Files\TDM-GCC-64

In my situation, I installed MinGW directly on the C drive. As such, my installation directory has the following layout:

C:\mingw64

  • C:\mingw64\bin
  • C:\mingw64\etc
  • C:\mingw64\*...

Once that is installed, all you need to do is point Matlab to the installation directory, in my case, I need to run the following command:

setenv('MW_MINGW64_LOC','C:\mingw64')

After that, you should be squared away to run the mex compilation command.