Visual Studio 2022 Compiler Not Found in Matlab 2026a.

I'm not sure if this is a Matlab issue or a windows issue, but hopefully someone can point me in the right direction.
I'm using the ROS2 Toolbox, so I need Visual Studio 2022. I installed it on my Windows 11 desktop using winget then used Modify to make sure Desktop Development with C++ was installed including MSVC v143 and Windows 11 SDK.
I verified the installation path was correct at C:Program Files\Microsoft Visual Studio\2022\Community. Here is an excerpt from the output for mex -setup -v C++.
... Looking for compiler 'Microsoft Visual C++ 2022' ...
... 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 "[17.0,18.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 "[17.0,18.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 "[17.0,18.0)" -products Microsoft.VisualStudio.Product.Community -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 "[17.0,18.0)" -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2022'.
It seems this vswhere.exe program that it is running is failing to find the compiler. I've already tried 1) restarting the computer, 2) using the Repair feature.
Thanks in advance!
-Kory

9 Comments

I also have Visual Studio Build Tools 2022
One other potentially helpful piece of info. When I run vswhere through windows powershell it is able to find the 2022 installation.
PS C:\WINDOWS\system32> & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -products * -property installationPath
C:\Program Files\Microsoft Visual Studio\2022\Community
C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
Hi,
according to https://github.com/microsoft/vswhere/wiki/Versions , the option -version "[17.0,18.0)" indicates that version 18.0 is excluded. Thus, one approach would be to get a slightly older version of VS 2022 or use VS 2019. According to https://de.mathworks.com/help/ros/gs/ros-system-requirements.html , VS 2019 is recommended over VS 2022.
Best wishes,
Harald
(note: I am not an expert on ROS[2])
@Harald the second link doesn't seem to work?
Seems awfully restrictive that only 17.0 appears allowed. I think I'd at least try changing to
-version "17.0" which would indicate 17 or newer and just takes my chances...until proven it doesn't work.
Thanks for the ideas - I contacted Matlab support about it as well, and will post here if I get a fix. To address @Harald's comment, I am using Version 17.14.41 of Visual Studio 2022, which should fall into the [17.0, 18.0) range.
Microsoft Visual Studio Community 2022
Version 17.14.41 (September 2026)
VisualStudio.17.Release/17.14.41+37710.0.-september.2026-
Microsoft .NET Framework
Version 4.8.09221
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA947
Microsoft Visual C++ 2022
...
If I can't fix the issue in 2022 I will also try 2019, as both are supposed to be supported.
Ah, so! That would be indicative to me of a bug in the implementation of the searching logic then -- and an explanation behind the fact that it was found in/with powershell and not cmd shells--the cmd version probably isn't designed to handle more than a 2-section version string, not the observed 3 sections. Never messed with it so not sure if the user has the flexibility to fixup the version id string or not...if so it would be interesting exercise to see if could specify the known exact version string just to workaround the apparent bug.
@dpb, sorry - a comma had slipped into the end of the URL. I have corrected the link above.
I cannot speak to the reasons why certain versions are supported or not. One reason why a more recent version of a third party software is not supported can be that it was not available sufficiently early.
@Kory, I am not overly familiar with how Microsoft assigns its VS version numbers. I would however like to point out that a VS version released in Sept. 2026 cannot have been tested with the R2026a shipping release. There may or may not have been changes that affect your workflows, I'd say it's somewhat a matter of luck.
Contacting Support is definitely a good idea because the question will be routed to a specialist on the topic. No, not me. ;)
Microsoft Learn indicates vswhere uses an internal COM API to query state rather than a registry or direct drive path search. That would imply it would break if something were wrong there in the install besides. I tried the two pertinent searches here...I use the JPSoftware Take Command Console (tcc) shell, hence the alias to define the location first...
C:\> alias vswhere "c:\Program Files (x86)\microsoft visual studio\installer\vswhere.exe" %&
C:\> vswhere -version "[17.0,18.0)" -products Microsoft.VisualStudio.Product.Community -property installationPath -format value
C:\Program Files\Microsoft Visual Studio\2022\Community
C:\> vswhere -version "[17.0,18.0)" -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value
C:\>
which, looks like it found the VS Community install but that I didn't install the BuildTools -- since never really used it, didn't ever miss it, but the command itself seems to have worked. That to me implies something is broken in the install rather than in MATLAB if your standalone execution doesn't find it.
The MS site also indicated that it will only return complete and startable instances, so if there were some issue there it would also fail. It suggested adding "-prerelease" and "-all" to include prerelease and installations that are in an incomplete or errored state. That might just uncover some issue to help resolve the problem.
I am still on Win10, though, not W11...
ADDENDUM
What about just running
vswhere -version "[17.0,18.0)"
at the command line? That will dump whatever it finds full database which might be interesting/useful to see. If that fails, then try with the "-all" switch.
ADDENDUM SECUNDUM
vswhere -all
on its own might be interesting, too...

Sign in to comment.

 Accepted Answer

Kory
Kory on 5 Oct 2026
Edited: Kory on 5 Oct 2026
Okay, I figured it out. On my windows computer I had a old code that run automatically each time the terminal was opened that was actually a script related to setting up some Anaconda dependencies, unrelated to Matlab or Visual Studio. I removed Anaconda a while ago, and it turned out the auto run was still running. The effect of this what that when the terminal opened, it would print out a "Path not found" warning, then function as normal.
This must have caused mex -setup c++ to return an error each time Matlab spawned a terminal to run vswhere. Rather than report an error, the setup instead just reported that no c++ compiler was found. I removed the AutoRun from the terminal and the mex setup immediatly succeeded the next time I ran it.

More Answers (0)

Categories

Products

Release

R2026a

Asked:

on 30 Sep 2026

Edited:

on 5 Oct 2026

Community Treasure Hunt

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

Start Hunting!