| Real-Time Workshop® | ![]() |
emlc [-options] [files] fcn
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:
Converts the M-function fcn.m to a C MEX function
Generates a platform-specific MEX file in the current directory
Generates the necessary wrapper files — such as C, header, object, and map files — in the subdirectory emcprj/ mexfcn/fcn/
You can change the default behavior by specifying one or more compilation options as described in 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:
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 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 Type | target Subdirectory |
|---|---|
| default | mexfcn |
| -T MEX | mexfcn |
| -T RTW:EXE | rtwexe |
| -T RTW:LIB | rtwlib |
Note To specify a compilation target type, see -T Specify Target. |
-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 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.
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 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 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 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 name | Copies the MEX-file to the current directory |
| An existing path | Generates 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 exist | Generates 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 optimization_option
Specify compiler optimization_option with one of the following literals (no quotes):
| Compiler Optimization Option | Action |
|---|---|
| disable:inline | Disable function inlining. |
| enable:inline | Enable function inlining (default). |
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 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.
| Property | Default |
|---|---|
| Name | 'Automatic C MEX Generation' |
| EnableDebugging | false |
| GenerateReport | false |
| LaunchReport | false |
| CustomSourceCode | '' |
| CustomHeaderCode | |
| CustomInitializer | |
| CustomTerminator | |
| CustomInclude | |
| CustomSource | |
| CustomLibrary |
Defaults for emlcoder.RTWConfig.
| Property | Default |
|---|---|
| Name | 'Real-Time Workshop' |
| RTWVerbose | false |
| GenCodeOnly | false |
| GenerateMakefile | true |
| GenerateReport | false |
| LaunchReport | false |
| MaxIDLength | 31 |
| GenFloatMathFcnCalls | 'ANSI_C' |
| MakeCommand | 'make_rtw' |
| TemplateMakeFile | 'grt_default_tmf' |
| PostCodeGenCommand | '' |
| CustomSourceCode | |
| CustomHeaderCode | |
| CustomInitializer | |
| CustomTerminator | |
| CustomInclude | |
| CustomSource | |
| CustomLibrary |
Defaults for emlcoder.HardwareImplementation.
| Property | Default |
|---|---|
| Name | 'Hardware Implementation' |
| ProdHWDeviceType | 'Generic->MATLAB Host Computer' |
| ProdBitPerChar | 8 |
| ProdBitPerShort | 16 |
| ProdBitPerInt | 32 |
| ProdBitPerLong | 32 |
| ProdWordSize | 32 |
| ProdShiftRightIntArith | true |
| ProdEndianess | 'LittleEndian' |
| ProdIntDivRoundTo | 'Zero' |
Defaults for emlcoder.CompilerOptions.
| Property | Default |
|---|---|
| ConstantFoldingTimeout | 10000 |
| InlineThreshold | 10 |
| InlineThresholdMax200 | 200 |
| InlineStackLimit | 4000 |
| SaturateOnIntegerOverflow | true |
| StackUsageMax | 200000 |
-T target_option
Specify a target option as follows:
| Target Option | Action |
|---|---|
| mex | Generate a C MEX function (default). |
| rtw or rtw:exe | Generate embeddable C code and compile it to an executable (.exe file). |
| rtw:lib | Generate embeddable C code and compile it to a library (.lib file). |
Note The rtw:exe, rtw, and rtw:lib options require a Real-Time Workshoplicense. |
See Choosing Your Target.
Enable verbose mode to show compilation steps.
Display theemlc command help.
![]() | addSourcePaths | findIncludeFiles | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |