Matlab cannot find the compiler problem, version general method

Many people have encountered the problem that when running mex -setup in matlab,
it prompts that mex cannot find a supported compiler or SDK. This article may help you solve problems that are not mentioned in most other articles. It is also the most fatal and difficult problem.

The root cause of the problem is the error caused by the installation path problem, and MATLAB cannot automatically recognize the path change.

The matlab I installed, VS2019 is not in the default path, and my MATLAB is on the D drive, and my VS2019 is on the E drive

Let me talk about my situation first. I installed matlab 2014b first, and then VS2019.

However, when I run the mex -setup command in matlab, this error appears.

I looked at many solutions online and found that I still couldn't solve the problem. I was very distressed, so I uninstalled and reinstalled matlab2018b. I thought this would work. However! ! ! Still not working, I vomited blood. In 2018b, the error message changed this time. It prompted me to install the MinGW-w64 C/C++ compiler, but I installed VS2019, and I was stubborn and didn’t want to install another compiler.

Into the title

Environment: win10, matlab2018b, VS2019

Theoretically, my solution is applicable to all versions

one,

  1. First enter the folder, D:\MATLAB\R2018b\bin\win64\mexopts (find it according to the MATLAB installation path you choose)
  2. Check to see if you have your VS version. Mine is VS2019, so I put the 2019 xml file in it.

If you have your version of VS, don't worry about it. If you don't have it, you can download the file here, which contains these versions https://download.csdn.net/download/no_say_you_know/12119043

After putting it in, you can open MATLAB and try the mex -setup command again. If not, please continue to the next step

two,

  1. Run mex -setup -v in the MATLAB command line. Since there was no screenshot at the time, I will not look at the VS2019 part of this picture. You can see that the following are all yes and no, and they cannot be found.
  2. Enter the troubleshooting stage, enter the registry, press "win+r" on the keyboard, enter "regedit" to open the registry, and search one by one.
  3. Taking the first item as an example, "HKLM" means: HKEY_LOCAL_MACHINE in the registry; "HKCU" means: HKEY_CURRENT_USER in the registry. Find "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" in the registry. If not,
    create corresponding entries in the corresponding directories, as shown in the figure. I do not have these paths myself, I added them myself.
  4. In the same way, open the "16.0" string under the registry key "HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" and assign the address of the "VC" file directory in the "Visual Studio" installation directory to it.
  5. Run mex -setup -v again. If the following picture appears, it means that the registry is resolved, but there is a path problem that is still not resolved.
  6. Open the two files msvc2019.xml and msvcpp2019.xml (choose according to your own VS version) in D:\MATLAB\R2018b\bin\win64\mexopts, find the two places, and compare your own VS installation path

 

You can find that the paths are different. You only need to copy the installation path of VS and replace it. Note that there are two such places in one file. Both files need to be modified.

three,

  1. Then open D:\MATLAB\R2018b\bin\win64\mexopts\compilerComponents, open the file below, and modify the path to your own VS installation path
  2.  Run the mex -setup -v command again, and now you can see this interface.

Since I wrote it after the fact, some steps may be incomplete or unclear, so please forgive me!

Guess you like

Origin blog.csdn.net/no_say_you_know/article/details/104082496