mex setup no longer finds compiler
Afficher commentaires plus anciens
I use Matlab 2019a and 2020b on Windows 10 with Visual Studio 2019. In the past I was able to build mex code, but now I can no longer find a compiler. The following changes might be relevant:
- Updated Microsoft Visual Studio Professional 2019 to version 16.8.4
- Installed Matlab Compiler on Matlab 2020b (no changes were made to 2019a, but it no longer works either)
After looking into this, it seems that calls to cmdReturns in msvcpp2019.xml always fail, and I haven't been able to find anyone with a similar issue. Here is the relevant output from mex -v -setup cpp:
... Looking for compiler 'Microsoft Visual C++ 2019' ...
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2019'.
The call to vswhere.exe is failing; however, if I run the same command in a command prompt I do get output:
C:\>"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
To eliminate vswhere as the culprit, I added the following lines to msvcpp2019.xml:
<cmdReturns name="echo hello" />
<cmdReturns name="call echo hello" />
Which returns:
... Executing command 'echo hello' ...No.
... Executing command 'call echo hello' ...No.
So, it seems that cmdReturns always fails. What could be causing this?
Réponse acceptée
Plus de réponses (2)
Suryaansh Mata
le 18 Fév 2021
0 votes
The issue looks similar to the one below. Give a try to the steps suggested for the same.
Additionally, this might be due to issues with the key in the registry or environment variables. Reinstallation should add the right key in the registry and set the required env var
DISCLAIMER: These are my own views and in no way depict those of MathWorks.
4 commentaires
John Morgan
le 18 Fév 2021
John Morgan
le 18 Fév 2021
zihui lang
le 14 Jan 2022
Hi there, I have a similar issue to John's but mine probabaly easier to solve. In my case, if I put the
C:\>"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value
in my cmd. It won't gives me any return. I re-install my visual studio for several times and makes sure I'm including the vs2019 builder (MSDV v142) but this problem still shows up. When I put
mex -setup -v
in my matlab, here is what it returns.
... Looking for compiler 'Microsoft Visual C++ 2019 (C)' ...
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2019 (C)'.
I believe this is because my vswhere.exe is not working properly, but how should I fix it?
Thanks and looking forward to your reply,
Best,
Zihui
Claudio Ferrara
le 12 Fév 2022
Chris Marsh
le 29 Mar 2022
Hi,
I seem to have exactly the same problem.
I was using 2021b quite happily auto generating code from simulink (using VS 2019)
I then had to install 2021a (as another project was using this version)
After this Matlab (2021a or 2021b) cannot find my compiler.
I've tried re-installing everything VS and matlab version and rebooting countless times to no aval.
Help!!!
... Looking for compiler 'Microsoft Visual C++ 2019 (C)' ...
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.
... Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.
... Executing command '"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version "[16.0,17.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2019 (C)'.
Error using mex
Supported compiler not detected. 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.
3 commentaires
John Morgan
le 29 Mar 2022
Chris Marsh
le 29 Mar 2022
Hi,
Thanks for getting back to so fast.
So, forgive me, i didn't quite understand the "If /D was NOT specified on the command line, then when CMD.EXE starts,". part of your comment, could you explain a little more?
I looked at my registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

Which I believe is as expected / is correct.
The second part does not exist in my registry, which I'm not sure whether that is a problem or not ?
** Note lack of ...Microsoft\Command Processor\AutoRun

John Morgan
le 29 Mar 2022
Modifié(e) : John Morgan
le 29 Mar 2022
Catégories
En savoir plus sur MATLAB Support for MinGW-w64 C/C++ Compiler dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!