www.gusucode.com > simulinkcoder 案例源码程序 matlab代码 > simulinkcoder/CompileAndDebugCCodeWithVisualStudioExample.m

    %% Compile and Debug Generated C Code with Microsoft(R) Visual Studio(R)
% 
% This example shows how to generate code from a model and produce  
% a Visual Studio Solution. For the base example, see |rtwdemo_counter|.
% 
%% About This Example
% Building this example model generates a Visual Studio Solution. These
% configuration settings control this code generation:
%
% * Target - Select *Configuration Parameters* > *Code Generation* > *System target file* as |grt.tlc Create Visual C/C++ Solution file for Simulink Coder|.
%
% * Template makefile - Select *Configuration Parameters* > *Code Generation* > *Template makefile* as |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.
%
%% Before You Start
% 
% * This example builds code for Microsoft Visual Studio running on Microsoft Windows(R) 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.
% 
%% Example Steps
% 
% # Open the example model |rtwdemo_counter_msvc|. In the Command Window, type:
% <matlab:open_system('rtwdemo_counter_msvc'); open_system('rtwdemo_counter_msvc');>
% # To generated debug output in the generated Visual Studio Solution, set the 
% *Configuration Parameters* > *Code Generation* > *Make command* parameter
% to |make_rtw DEBUG_BUILD=1|. (Omit this step if debug output is not
% required in the solution.)
% # To generate code, double click the *Generate Code Using Simulink Coder* button in the model or at the command prompt, type:
% <matlab:rtwbuild('rtwdemo_counter_msvc'); rtwbuild('rtwdemo_counter_msvc');>  
% # After the build process is complete, you can see a Visual Studio Solution was generated and placed in the |msvc| folder under the |rtwdemo_counter_msvc_grt_rtw| folder.
% # 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.
%