This example shows how to generate code from a model and produce a Visual Studio Solution. For the base example, see rtwdemo_counter
.
Building this example model generates a Visual Studio Solution. These model configuration parameter settings control this code generation:
Set System target file to grt.tlc
.
Set Template makefile to RTW.MSVCBuild
.
When you build the model with this configuration, Simulink Coder generates code in a Visual Studio Solution. Add this solution to a Visual Studio C/C++ project to integrate generated code with your custom Visual Studio code.
This example builds code for Microsoft Visual Studio running on Microsoft Windows® platforms.
This example works with Microsoft Visual Studio, but not with Visual Studio Express.
Simulink Coder uses the GRT code format, which is intended for rapid prototyping.
Embedded Coder uses the ERT code format, which is intended for production deployment.
Open the example model rtwdemo_counter_msvc
. In the Command Window, type: open_system('rtwdemo_counter_msvc');.
To generate debug output in the generated Visual Studio Solution, set the model configuration parameter Make command to make_rtw DEBUG_BUILD=1
. (Omit this step if debug output is not required in the solution.)
To generate code and build a program executable, initiate the build process.
After the build process is complete, you can see a Visual Studio Solution was generated and placed in the msvc
folder under folder rtwdemo_counter_msvc_grt_rtw
.
In Microsoft Visual Studio, open the rtwdemo_counter_msvc.sln
solution file.
Use the solution to build and debug the generated code in Visual Studio.