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 application:
1. Develop your model. For this example, open the model
rtwdemo_shrlib. Save a copy of the model to a writable location.
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. Open the Embedded Coder app.
3. Set model configuration parameter System target file to
4. 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
5. Create application code that uses the shared library. This example uses application code that is available in these files:
To view the source code in these files, in the model, click the white buttons for the
6. 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.