Visual Studio 2022 Compiler Not Found in Matlab 2026a.
Show older comments
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
Kory
on 30 Sep 2026
Kory
on 30 Sep 2026
Torsten
on 30 Sep 2026
Contact support:
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])
Kory
on 1 Oct 2026
dpb
on 1 Oct 2026
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.
Harald
on 2 Oct 2026
@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...
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!