emlc - Generate C code or C MEX code directly from M-code

Syntax

emlc [-options] [files] fcn

Description

emlc invokes the Embedded MATLAB™ Coder from the MATLAB® command prompt.

emlc [-options] [files] fcn translates the M-file fcn.m to a C MEX file or to embeddable C code, depending on the target you specify as an option on the command line (see -T Specify Target in Options). If you generate embeddable C code, you can specify custom files to include in the build, as described in Specifying Custom C Files on the Command Line in the Real-Time Workshop® documentation.

By default, emlc fcn does the following:

You can change the default behavior by specifying one or more compilation options as described in Options.

Options

You can specify one or more compilation options with each emlc command. Use spaces to separate options and arguments. Embedded MATLAB Coder resolves options from left to right, so if you use conflicting options, the rightmost one prevails. Here is the list of emlc options:

-c Generate Code Only

Generate code, but do not invoke the make command. Embedded MATLAB Coder does not compile the M-code or build a C code executable. Use this option only for rtw, rtw:exe, and rtw:lib targets (see -T Specify Target).

-d Specify Output Directory

-d out_directory

Store generated files in directory path specified by out_directory. If any directories on the path do not exist, Embedded MATLAB Coder creates them for you. out_directory can be an absolute path or relative path. If you do not specify an output directory, Embedded MATLAB Coder stores generated files in a default subdirectory:

emcprj/target/function

target represents the compilation target type, specified as follows:

Target Typetarget Subdirectory
defaultmexfcn
-T MEXmexfcn
-T RTW:EXErtwexe
-T RTW:LIBrtwlib

-eg Specify Input Properties by Example

-eg example_inputs

Use the values in cell array example_inputs as sample inputs for defining the properties of the primary M-function inputs. The cell array should provide the same number and order of inputs as the primary function. See Defining Input Properties by Example at the Command Line .

-F Specify Default fimath

-F fimath

Use fimath as the default fimath object for all fixed-point inputs to the primary function. You can define the default value using the Fixed-Point Toolbox™ fimath function, as in this example:

emlc -F fimath('OverflowMode','saturate','RoundMode','nearest')

Embedded MATLAB Coder uses the default value if you have not defined any other fimath property for the primary, fixed-point inputs, either by example (see Defining Input Properties by Example at the Command Line) or programmatically (see Defining Input Properties Programmatically in the M-File). If you do not define a default value, then you must use one of the other methods to specify the fimath property of your primary, fixed-point inputs.

-g Compile C MEX Function in Debug Mode

Compile the C MEX function in debug mode, with optimization turned off. Applies only to C MEX generation. If you do not specify -g, emlc compiles the C MEX function in optimized mode. You specify these modes using the mex -setup procedure described in Building Binary MEX-Files in the online MATLAB External Interfaces documentation.

-I Add Directories to Embedded MATLAB™ Path

-I include_path

Add include_path to the Embedded MATLAB path. By default, the Embedded MATLAB path consists of the current directory (pwd) and the Embedded MATLAB libraries directory. emlc searches the Embedded MATLAB path first when converting M-code to C code. See File Paths and Naming Conventions.

emlc searches directories from left to right.

-N Specify Default Numeric Type

-N numerictype

Use numerictype as the default numerictype object for all fixed-point inputs to the primary function. You can define the default value using the Fixed-Point Toolbox numerictype function, as in this example:

emlc -N numerictype(1,32,23) myFcn

This command specifies that the numeric type of all fixed-point inputs to the top-level function myFcn be signed (1), have a word length of 32, and have a fraction length of 23.

Embedded MATLAB Coder uses the default value if you have not specified any other numerictype for the primary, fixed-point inputs, either by example (see Defining Input Properties by Example at the Command Line) or programmatically (see Defining Input Properties Programmatically in the M-File). If you do not define a default value, then you must use one of the other methods to specify the numerictype of your primary, fixed-point inputs.

-o Specify Output File Name

-o output_file_name

Generate the final output file—that is, the C MEX function, Real-Time Workshop executable, or Real-Time Workshop library— with the base name output_file_name. If the output file is a C MEX function, Embedded MATLAB Coder assigns it a platform-specific extension.

You can specify output_file_name as a file name or an existing path, with the following effects:

If you specify:emlc:
A file nameCopies the MEX-file to the current directory
An existing pathGenerates the MEX-file in the directory specified by the path, but does not copy the MEX-file to the current directory
A path that does not existGenerates an error

Embedded MATLAB Coder generates the supporting C files with the same base name as the corresponding M-files, replacing the .m extension with .c.

-O Specify Compiler Optimization Option

-O optimization_option

Specify compiler optimization_option with one of the following literals (no quotes):

Compiler Optimization OptionAction
disable:inlineDisable function inlining.
enable:inlineEnable function inlining (default).

-report Generate Compilation Report

Generate a compilation report. If this option is not specified, emlc generates a report only if there are compilation messages. See Working with Compilation Reports.

-s Specify Configuration Properties

-s config_object

Generate code based on the properties of configuration object config_object. When you specify conflicting configuration objects on the command line, the rightmost configuration object prevails. For detailed information about working with configuration objects, see Configuring Your Environment for Code Generation.

If a configuration object is not specified, Embedded MATLAB Coder uses default property values, as follows:

Defaults for emlcoder.MEXConfig.  
PropertyDefault
Name'Automatic C MEX Generation'
EnableDebuggingfalse
GenerateReportfalse
LaunchReportfalse
CustomSourceCode''
CustomHeaderCode
CustomInitializer
CustomTerminator
CustomInclude
CustomSource
CustomLibrary

Defaults for emlcoder.RTWConfig.  
PropertyDefault
Name'Real-Time Workshop'
RTWVerbosefalse
GenCodeOnlyfalse
GenerateMakefiletrue
GenerateReportfalse
LaunchReportfalse
MaxIDLength31
GenFloatMathFcnCalls'ANSI_C'
MakeCommand'make_rtw'
TemplateMakeFile'grt_default_tmf'
PostCodeGenCommand''
CustomSourceCode
CustomHeaderCode
CustomInitializer
CustomTerminator
CustomInclude
CustomSource
CustomLibrary

Defaults for emlcoder.HardwareImplementation.  
PropertyDefault
Name'Hardware Implementation'
ProdHWDeviceType'Generic->MATLAB Host Computer'
ProdBitPerChar8
ProdBitPerShort16
ProdBitPerInt32
ProdBitPerLong32
ProdWordSize32
ProdShiftRightIntArithtrue
ProdEndianess'LittleEndian'
ProdIntDivRoundTo'Zero'

Defaults for emlcoder.CompilerOptions.  
PropertyDefault
ConstantFoldingTimeout10000
InlineThreshold10
InlineThresholdMax200200
InlineStackLimit4000
SaturateOnIntegerOverflowtrue
StackUsageMax200000

-T Specify Target

-T target_option

Specify a target option as follows:

Target OptionAction
mexGenerate a C MEX function (default).
rtw
or
rtw:exe
Generate embeddable C code and compile it to an executable (.exe file).
rtw:libGenerate embeddable C code and compile it to a library (.lib file).

See Choosing Your Target.

-v Show Compilation Steps

Enable verbose mode to show compilation steps.

-? Display Help

Display theemlc command help.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS