mex setup no longer finds compiler

160 visualizaciones (últimos 30 días)
John Morgan
John Morgan el 29 de En. de 2021
Comentada: Rihan Dsilva el 27 de Mzo. de 2024 a las 9:25
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?

Respuesta aceptada

John Morgan
John Morgan el 24 de Feb. de 2021
I've finally fixed this! I noticed that whenever I started up a command pompt, the following appeared at the top of the window:
Microsoft Windows [Version 10.0.18363.1379]
(c) 2019 Microsoft Corporation. All rights reserved.
The system cannot find the path specified.
After searching for what could be causing the "The system cannot find the path specified." message I came across the advice to clear the following registry values:
  • HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
For me, the first value was populated with a conda_hook.bat file that didn't exist. After clearing the value, Matlab is able to find my compiler.
  1 comentario
Rihan Dsilva
Rihan Dsilva el 27 de Mzo. de 2024 a las 9:25
I have the same prolem. However, even after this fix, the problem persists. Was anyone able to solve this issue?

Iniciar sesión para comentar.

Más respuestas (2)

Suryaansh Mata
Suryaansh Mata el 18 de Feb. de 2021
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 comentarios
zihui lang
zihui lang el 14 de En. de 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
Claudio Ferrara el 12 de Feb. de 2022
Hi @zihui lang I have the same problem now. Did you manage to solve the problem?

Iniciar sesión para comentar.


Chris Marsh
Chris Marsh el 29 de Mzo. de 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 comentarios
Chris Marsh
Chris Marsh el 29 de Mzo. de 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
John Morgan el 29 de Mzo. de 2022
Editada: John Morgan el 29 de Mzo. de 2022
It's ok if there's no AutoRun variable; however, I believe the Command Processor folder should be there. This link might help: https://answers.microsoft.com/en-us/windows/forum/all/accidentally-deleted-command-processor-folder-in/2766c101-9e94-42e2-97e9-69def29da767 you may need to do a repair install

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by