MATLAB: How to install Visual Studio 2017 or 2019 for use with MATLAB/Simulink

Embedded CoderMATLABmatlab codersimulinksimulink coderstateflow

I would like to use the Visual Studio 2017 or 2019 C/C++ compiler with MATLAB/Simulink. When installing Visual Studio, there are many packages (so-called "workloads") to choose from. Which Visual Studio workloads do I need to install?

Best Answer

Before you proceed, double-check which Visual Studio version is supported with your MATLAB release . Note that:
  • Visual Studio 2017 family has been supported since R2016b
  • Visual Studio 2019 family has been supported since R2019a
  • Community (free), Professional, and Enterprise editions are supported
You can download Visual Studio here:
While running the installer for Visual Studio, make sure that the "Desktop development with C++" workload is selected, as shown in the screenshot below. This will make sure that the actual Visual Studio C++ (MSVC) compiler and all necessary dependencies are installed on your system.
For detailed instructions on how to install Visual Studio C++, refer to the following Microsoft articles:
To use Visual Studio 2017 with Simulink Real-Time, additionally refer to the following article:
Related Question