Install Visual Studio 2017 with Windows 10 SDK and VC++ 2017 toolset:
1) Begin installing your edition of Visual Studio 2017 as normal or if you have already installed Visual Studio 2017, run the Visual Studio Installer and skip to step (3) in this section.
2) Once Visual Studio 2017 is installed, the buttons Update, Launch, and a hamburger menu will appear.
3) Click on the hamburger menu and choose Modify.
4) This will bring up the "Modifying" dialog box.
5) Click on the Individual components tab.
Check the box for Windows 10 SDK, VC++ 2017 toolset (v141 tools) and the following Visual Studio C++ core features.
- Windows 10 SDK (10.0.17134.0 or earlier) under SDKs, libraries, and frameworks.
- VC++ 2017 version 15.8 v14.15 (latest v141 tools) under Compilers, build tools, and runtimes
- Visual Studio C++ core features under Development Activities.
CAUTION: *Do not install Windows 10 SDK (10.0.17763.0)* or a later version. This is known to cause an error on the target upon loading the application (Unable to load DLL dependency: kernel32.dll.GetFileSizeEx).
Click the Modify button.
6) Visual Studio 2017 will now start adding the necessary components to its installation.
Set up MATLAB and Simulink Real-Time to Detect Visual Studio 2017 Compiler:
1) If using R2016b or R2017a, install patches that will allow MATLAB and Simulink to detect the Visual Studio 2017 compiler. All patches must be installed in the following order:
MEX-file compilation, MATLAB Compiler and MATLAB Compiler SDK:
*Simulink Coder: *
*Simulink Real-Time: *
2) Execute the following (note, this will remove all support packages and custom libraries, so they need to be reinstalled or added back to the path):
3) Restart MATLAB.
5) Select Microsoft Visual C++ 2017 (C)
6) Copy the attached timestwo.c file to an empty directory to make sure that you can mex. Then, execute
7) If mex works without error, you can now use Simulink Real-Time with the Visual Studio 2017 compiler. If you are using Speedgoat libraries, they can now be installed. Make sure that you install the latest Speedgoat libraries.
Note:In R2016b and R2017a, do NOT execute "slrtsetCC setup" to select Visual Studio 2017 as the compiler for SLRT because this may create an unusable MEX setup. Only "mex -setup" is required in R2016b and R2017a. If "slrtsetCC setup" has been called, delete the HostEnvSettings.xml file in the directory returned by executing "xpcprefdir" in the Command Window.
Troubleshooting:If you encounter build issues with your Simulink Real-Time model, check whether you can build with increasingly complex models. For example, begin by
- Making the example 'vdp' model fixed-step and building it (check if any Simulink model can be built)
- Building the example 'xpcosc' model (check if any Simulink Real-Time model can be built)
- Building an example Speedgoat model (if applicable, check if any Speedgoat model can be built)
- Finally, building your own model (check if the build issue is model-specific).
This helps narrow down the cause of the issue.