This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Interface to a Development Computer Simulator By Using a Shared Library

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 ert_shrlib.tlc.

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 rtwdemo_shrlib.


The model is a single-rate, discrete-time model. An 8-bit counter feeds the triggered subsystem named Amplifier. Parameters INC, LIMIT, and 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 rtwdemo_shrlib_win64.dll.

4. Create application code that uses the shared library. This example uses application code that is available in the these files:

matlabroot\toolbox\rtw\rtwdemos\shrlib_demo\rtwdemo_shrlib_app.h matlabroot\toolbox\rtw\rtwdemos\shrlib_demo\rtwdemo_shrlib_app.c

To view the source code in these files, in the model, click the white buttons for the .h and .c files.

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 .m file.

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.

Was this topic helpful?