| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop |
| Contents | Index |
| Learn more about Real-Time Workshop |
The shared utility directories (slprj/target/_sharedutils) typically store generated utility code that is common to a top model and the models it references. You can also force the build process to use a shared utilities directory for a standalone model. See Setting Up Runtime Logging to MAT-Files for details.
If you want your target to support compilation of code generated in the shared utilities directory, several updates to your template makefile (TMF) are required. Support for the shared utilities directory is a necessary, but not sufficient, condition for supporting model reference builds. See Supporting Optional Features to learn about additional updates that are needed for supporting model reference builds.
The exact syntax of the changes can vary due to differences in the make utility and compiler/archive tools used by your target. The examples below are based on the Free Software Foundation's GNU® make utility. You can find the following updated TMF examples for GNU and Microsoft® Visual C++® make utilities in the GRT and ERT target directories:
GRT: matlabroot/rtw/c/grt/
grt_lcc.tmf
grt_vc.tmf
grt_unix.tmf
ERT: matlabroot/rtw/c/ert/
ert_lcc.tmf
ert_vc.tmf
ert_unix.tmf
Use the GRT or ERT examples as a guide to the location, within the TMF, of the changes and additions described below.
Note The ERT-based TMFs contain extra code to handle generation of ERT S-functions and model reference simulation targets. Your target does not need to handle these cases. |
Make the following changes to your TMF to support the shared utilities directory:
Add the following make variables and tokens to be expanded when the makefile is generated:
SHARED_SRC = |>SHARED_SRC<| SHARED_SRC_DIR = |>SHARED_SRC_DIR<| SHARED_BIN_DIR = |>SHARED_BIN_DIR<| SHARED_LIB = |>SHARED_LIB<|
SHARED_SRC specifies the shared utilities directory location and the source files in it. A typical expansion in a makefile is
SHARED_SRC = ../slprj/ert/_sharedutils/*.c
SHARED_LIB specifies the library file built from the shared source files, as in the following expansion.
SHARED_LIB = ../slprj/ert/_sharedutils/rtwshared.lib
SHARED_SRC_DIR and SHARED_BIN_DIR allow specification of separate directories for shared source files and the library compiled from the source files. In the current release, all TMFs use the same path, as in the following expansions.
SHARED_SRC_DIR = ../slprj/ert/_sharedutils SHARED_BIN_DIR = ../slprj/ert/_sharedutils
Set the SHARED_INCLUDES variable according to whether shared utilities are in use. Then append it to the overall INCLUDES variable.
SHARED_INCLUDES =
ifneq ($(SHARED_SRC_DIR),)
SHARED_INCLUDES = -I$(SHARED_SRC_DIR)
endif
INCLUDES = -I. $(MATLAB_INCLUDES) $(ADD_INCLUDES) \
$(USER_INCLUDES) $(SHARED_INCLUDES)
Update the SHARED_SRC variable to list all shared files explicitly.
SHARED_SRC := $(wildcard $(SHARED_SRC))
Create a SHARED_OBJS variable based on SHARED_SRC.
SHARED_OBJS = $(addsuffix .o, $(basename $(SHARED_SRC)))
Create an OPTS (options) variable for compilation of shared utilities.
SHARED_OUTPUT_OPTS = -o $@
Provide a rule to compile the shared utility source files.
$(SHARED_OBJS) : $(SHARED_BIN_DIR)/%.o : $(SHARED_SRC_DIR)/%.c $(CC) -c $(CFLAGS) $(SHARED_OUTPUT_OPTS) $<
Provide a rule to create a library of the shared utilities. The following example is based on The Open Group UNIX platforms.
$(SHARED_LIB) : $(SHARED_OBJS) @echo "### Creating $@ " ar r $@ $(SHARED_OBJS) @echo "### Created $@ "
Add SHARED_LIB to the rule that creates the final executable.
$(PROGRAM) : $(OBJS) $(LIBS) $(SHARED_LIB)
$(LD) $(LDFLAGS) -o $@ $(LINK_OBJS) $(LIBS) $(SHARED_LIB)\
$(SYSLIBS)
@echo "### Created executable: $(MODEL)"Remove any explicit reference to rt_nonfinite.c or rt_nonfinite.cpp from your TMF. For example, change
ADD_SRCS = $(RTWLOG) rt_nonfinite.c
to
ADD_SRCS = $(RTWLOG)
![]() | Creating Reusable Components | Creating Component Object Libraries and Enhancing Simulation Performance | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |