Microsoft Visual Studio 2022 set up as default C and C++ compiler in Matlab 2021a

76 vues (au cours des 30 derniers jours)
That´s my need. It´s installed but Matlab doesn´t know that it is.
if I put: mex -setup, Microsoft visual studio doesn´t appear.
Thank you very much for helping!
What must I do in order to set Visual Studio as the Matlab C and C++ Compiler?
My default Compiler now is mingw64-g++ but I want to generate an audio plugin and it can´t be compiled, this is the message:
"Error using generateAudioPlugin
Toolchain 'MinGW64 Compiler (C++)' is not supported for generating audio plug-ins. Use one
of the following:
Microsoft Visual C++ 2017
Microsoft Visual C++ 2015."
Visual C++ is already installed in my desktop but how can I integrate it to MATLAB in order to be the compiler in use with it?
  2 commentaires
Federico Flores Richaud
Federico Flores Richaud le 23 Mar 2022
What must I do in order to set Visual Studio as the Matlab C and C++ Compiler?
My default Compiler now is mingw64-g++ but I want to generate an audio plugin and it can´t be compiled, this is the message:
"Error using generateAudioPlugin
Toolchain 'MinGW64 Compiler (C++)' is not supported for generating audio plug-ins. Use one
of the following:
Microsoft Visual C++ 2017
Microsoft Visual C++ 2015."
Visual C++ is already installed in my desktop but how can I integrate it to MATLAB in order to be the compiler in use?
mihai sava
mihai sava le 19 Avr 2023
In simple words, you can not!

Connectez-vous pour commenter.

Réponse acceptée

Jimmy Lapierre
Jimmy Lapierre le 29 Mar 2022
Plugin generation is part of the Audio Toolbox, which does not support MinGW. For plugins:
  • VS 2019 was added to R2019b (appears to be missing from the error message).
  • VS 2022 is planned for R2022a update 1. This and other releases subject to change.
For the latest, check the supported compilers page, including the link in the top right corner for previous releases.
  3 commentaires
nicholas roche
nicholas roche le 12 Sep 2024
To get MATLAB 2024a to recognise Microsoft Visual Studio Community 2022 as a compiler option for C++, I had to install 'MSVC v140 - VS 2015 c++ build tools'. Ensure you select this option when installing the 'Desktop Development with C++' workload.

Connectez-vous pour commenter.

Plus de réponses (4)

Benjamin Thompson
Benjamin Thompson le 22 Mar 2022
Modifié(e) : Benjamin Thompson le 22 Mar 2022
This was added in R2021B Update 3. Not sure if R2021A will ever get this update. VS 2022 was release only very recently.

Youssef Elshebani
Youssef Elshebani le 23 Juin 2022
i can't add the microsoft visual c++ compiler as well to my 2021b version of matlab, can you help me please
  2 commentaires
Jimmy Lapierre
Jimmy Lapierre le 23 Juin 2022
Which version of Visual C++ are you using?
Walter Roberson
Walter Roberson le 24 Juin 2022
I think I saw Youssef mention VS 2019 C++ in a different post.

Connectez-vous pour commenter.


CB
CB le 6 Juil 2024
Microsoft Visual Studio 2022 set up as default C and C++ compiler in Matlab 2023b
2023b does support MSVS2022, but...
If you are installing on Win10 when the "Desktop development with C++" workload is selected the default SDK is for Win11, you can uncheck that and save 2GB of space and check a Win10 SDK further down the list.
  1 commentaire
Ben
Ben le 19 Août 2025
This comment is what led me to the solution to the problem of VS C++ not showing as an option when running mex -setup cpp.
I had installed VS 2022 C++ build tools, but it was not an option in MATLAB until I installed the Windows SDK. This command also helped me understand what was happening: mex -setup cpp -v.

Connectez-vous pour commenter.


Xu Mingquan
Xu Mingquan le 26 Sep 2024
Modifié(e) : Xu Mingquan le 26 Sep 2024
Hi, I also encontered an issue when I ran Matlab 2023b with Microsoft Visual Studio 2022.
It told me the following error:
[GPU] : File mexcuda Line: 185
id:MATLAB:mex:Error msg:nvcc warning : The 'compute_35', 'compute_37', 'sm_35', and 'sm_37' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
set_views_gpu_mex.cu
D:\MATLAB2023b\sys\cuda\win64\cuda\include\crt/host_config.h(153): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
I have win 11, matlab2023b, Microsoft Visual Studio 2022, CUDA 12.2 on my PC with NVIDIA GeForce RTX 4080 SUPER.
The installation of Microsoft Visual Studio 2022 is shown below:
  4 commentaires
Harald
Harald le 14 Oct 2024
I would advise to use the CUDA Toolkit version that is compatible with MATLAB. For R2023b, this is 11.8 according to this table:
If you cannot roll back MVS 2022, an alternative could be to install MVS 2019.
Best wishes,
Harald
Xu Mingquan
Xu Mingquan le 14 Oct 2024
Thanks very much for your advice.
I will try your methods.

Connectez-vous pour commenter.

Catégories

En savoir plus sur C Shared Library Integration dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by