How I can set Microsoft Visual Studio 2017 compilers with MATLAB R2021a?

74 ビュー (過去 30 日間)
Adnan Ghaderi
Adnan Ghaderi 2022 年 12 月 28 日
コメント済み: Adnan Ghaderi 2023 年 1 月 9 日
Can I use Microsoft Visual Studio 2017 compilers with MATLAB R2021a?
I want to use mexopencv, but I can't set Microsoft Visual Studio 2017 in MATLAB, evenso I installed VS2017.
This is error when I am running mexopencv and mex -setup:
Error using mexOpenCV (line 73)
The OpenCV libraries were built using 'Microsoft Visual C++ 2017'.
Your compiler is 'MinGW64 Compiler (C)'.
These compilers may not be compatible.
Note that you can select a compiler using 'mex -setup' command.
>> mex -v -setup
... Looking for compiler 'Microsoft Visual C++ 2017 (C)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\').
... Executing command 'set "vcroot=C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer"&for /f "delims= " %a in ('type "C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"') do @if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\TeamExplorer\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe" call echo %vcroot%' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2017 (C)'.

採用された回答

Guru Kumaresan
Guru Kumaresan 2023 年 1 月 9 日
Hi Adnan,
By looking at the output from "mex -v -setup", the issue is caused by the Windows registry entry not pointing to the correct installation folder.
To resolve this issue for Visual Studio 2017, please reinstall it in "C:\Program Files (x86)\Microsoft Visual Studio\2017" and run "mex -v -setup" in MATLAB.
Since MATLAB has stopped relying on the registry entry from Visual Studio 2019, such issues will not be there with VS 2019 and later versions of VS.

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by