Main Content

rtw_precompile_libs

Rebuild precompiled libraries within model without building model

Description

example

rtw_precompile_libs(model,build_spec) builds libraries within model, according to the build_spec field values, and places the libraries in a precompiled folder. Model builds that use the template makefile approach support the rtw_precompile_libs function. Toolchain approach model builds do not support the rtw_precompile_libs function.

Examples

collapse all

Build the libraries in my_model without building my_model.

% Specify the library suffix
if isunix
   suffix = '_std.a';
elseif ismac
   suffix = '_std.a';
else
   suffix = '_vcx64.lib';
end
open_system(my_model);
set_param(my_model, 'TargetLibSuffix',suffix);

% Set the precompiled library folder
set_param(my_model, 'TargetPreCompLibLocation',fullfile(pwd,'lib'));

% Define a build specification that specifies 
% the location of the files to compile.
my_build_spec = [];
my_build_spec.rtwmakecfgDirs = {fullfile(pwd,'src')};

% Build the libraries in 'my_model'
rtw_precompile_libs(my_model,my_build_spec);

Input Arguments

collapse all

Name of the model containing the libraries that you want to build.

Structure with fields that define a build specification. Fields except rtwmakecfgDirs are optional.

Name-Value Pair Arguments

Example: build_spec.rtwmakecfgDirs = {fullfile(pwd, 'src')};

Specify the structure field values of the build_spec.

Uses the Name and Location elements of makeInfo.library, as returned by the rtwmakecfg function, to specify name and location of precompiled libraries. If you use the TargetPreCompLibLocation parameter to specify the library folder, it overrides the makeInfo.library.Location setting.

The specified model must contain S-function blocks that use precompiled libraries, which the rtwmakecfg files specify. The makefile that the build approach generates contains the library rules only if the conversion requires the libraries.

Example: build_spec.rtwmakecfgDirs = {fullfile(pwd, 'src')};

The suffix must include a period (.). Set the suffix by using either this field or the TargetLibSuffix parameter. If you specify a suffix with both mechanisms, the TargetLibSuffix setting overrides the setting of this field.

Example: build_spec.libSuffix = '_vcx64.lib';

When set to true, indicates that the function optimizes the libraries so that they compile from integer code only. Applies to ERT-based targets only.

Example: build_spec.intOnlyBuild = 'false';

Specifies an option to include in the rtwMake command line.

Example: build_spec.makeOpts = '';

This cell array of structures specifies the libraries to build that an rtwmakecfg function does not specify. Define each structure with two fields that are character arrays:

  • libName — Name of the library without a suffix

  • libLoc — Location for the precompiled library

The build approach (toolchain approach or template makefile approach) lets you specify other libraries and how to build them. Use this field if you must precompile libraries.

Example: build_spec.addLibs = 'libs_list';

Introduced in R2009b