For Matlab R2021a, How can Visual Studio be selected as the compiler for C/C++

20 次查看(过去 30 天)
I have installed matlab R2021a, CUDA 11.2, and visual studio 2022 community with MSVC v140 -Vs2015 C++ build tools (v14.00). But when I run "mex -setup " in matlab, I got the following error messages
>> mex -setup
Error using mex
Supported compiler not found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler. For more options, visit
If I run "mex -setup -v C++ " in matlab, I got the following messages.
>> mex -setup -v C++
Verbose mode is on.
... Looking for compiler 'Intel Parallel Studio XE 2018 for C++ with Microsoft Visual Studio 2015' ...
... Looking for environment variable 'ICPP_COMPILER18' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2018 for C++ with Microsoft Visual Studio 2015'.
... Looking for compiler 'Intel Parallel Studio XE 2018 for C++ with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'ICPP_COMPILER18' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2018 for C++ with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel Parallel Studio XE 2018 for C++ with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'ICPP_COMPILER18' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2018 for C++ with Microsoft Visual Studio 2019'.
... Looking for compiler 'Intel Parallel Studio XE 2019 for C++ with Microsoft Visual Studio 2015' ...
... Looking for environment variable 'ICPP_COMPILER19' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2019 for C++ with Microsoft Visual Studio 2015'.
... Looking for compiler 'Intel Parallel Studio XE 2019 for C++ with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'ICPP_COMPILER19' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2019 for C++ with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel Parallel Studio XE 2019 for C++ with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'ICPP_COMPILER19' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2019 for C++ with Microsoft Visual Studio 2019'.
... Looking for compiler 'Intel Parallel Studio XE 2020 for C++ with Microsoft Visual Studio 2017' ...
... Looking for environment variable 'ICPP_COMPILER20' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2020 for C++ with Microsoft Visual Studio 2017'.
... Looking for compiler 'Intel Parallel Studio XE 2020 for C++ with Microsoft Visual Studio 2019' ...
... Looking for environment variable 'ICPP_COMPILER20' ...No.
Did not find installed compiler 'Intel Parallel Studio XE 2020 for C++ with Microsoft Visual Studio 2019'.
... Looking for compiler 'MinGW64 Compiler (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...No.
Did not find installed compiler 'MinGW64 Compiler (C++)'.
... Looking for compiler 'MinGW64 Compiler with Windows 10 SDK or later (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...No.
Did not find installed compiler 'MinGW64 Compiler with Windows 10 SDK or later (C++)'.
... Looking for compiler 'Microsoft Visual C++ 2015' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 14.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 14.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' 14.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
Did not find installed compiler 'Microsoft Visual C++ 2015'.
... Looking for compiler 'Microsoft Visual C++ 2017' ...
... 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 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 15.0 ...No.
Did not find installed compiler 'Microsoft Visual C++ 2017'.
... 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'.
Error using mex
Supported compiler not found. 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.
Would you please give me some suggestions? Thanks!
Zhongxing

采纳的回答

Joss Knight
Joss Knight 2024-10-8
Using a 2022 compiler with a 2021 MATLAB isn't a supported workflow. Can you upgrade MATLAB?

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by