This example generates a shared library for interfacing to a simulator that runs on your development computer. Generate the shared library by using the system target file
To build a shared library from the model and use the library in an appplication:
1. Develop your model. For this example, open the model
The model is a single-rate, discrete-time model. An 8-bit counter feeds the triggered subsystem named
RESET are set to constant values 1, 4, and 0, respectively. When signal
equal_to_count is true, the subsystem amplifies its input signal by a gain factor
K=3 and the output signal is updated.
2. Configure the model for code generation, specifying
ert_shrlib.tlc as the system target file. Click the yellow button on the model to view the configuration settings on the Code Generation pane in the Configuration Parameters dialog box.
3. Build the shared library file. The file that the code generator produces depends on your development platform. For example, on a Windows system, the code generator produces the library file
4. Create application code that uses the shared library. This example uses application code that is available in the these files:
To view the source code in these files, in the model, click the white buttons for the
5. Compile and link the file application and shared library files to produce an executable program. The following script compiles, builds, and runs the program.
To view the script code, in the model, click the white button for the
To build the model and run the application that uses the generated shared library, in the model, double-click the blue button.
For more information about using a shared library, see Package Generated Code as Shared Libraries.