Skip to content

mcc

miscellaneous · scripts/miscellaneous/mcc.m

: mcc [-options] file …
: status = mcc (…)

Compile MATLAB/Nexus .m files to standalone executables, C shared libraries, or pack them into a deployable CTF archive.

This function provides MATLAB Compiler (MCC) compatibility for Nexus, allowing users to compile .m files into standalone executables that can run without Nexus installed (requires Nexus runtime libraries), to emit a C shared library (-W lib:libname / -l), or to package sources into a ZIP-based .ctf archive.

status is the return status of the compilation process (0 on success).

If the compilation fails, and the output argument is not requested, an error is raised. If the programmer requests status, however, Nexus will merely issue a warning and it is the programmer’s responsibility to verify the command was successful.

mcc accepts the following options, compatible with MATLAB’s MCC:

‘-m’

Generate standalone application (equivalent to -W main -T link:exe).

‘-l’

Generate a C shared library (equivalent to -W lib -T link:lib). Library name defaults to the first input file basename.

‘-W lib:libname’

Wrapper type for a C shared library named libname. Emits libname.h, the shared .so/.dll, generated library source, and a test.c stub caller (MATLAB R2026a mcc -W lib: semantics).

‘-T link:lib’
‘-T link:exe’

Target stage. Defaults to link:lib for -W lib and link:exe for -m/-W main.

‘-o outputname’
‘--output outputname’

Specify output executable name. Default is the name of the first input file.

‘-d outdir’
‘--outdir outdir’

Output directory for generated artefacts (MATLAB mcc -d).

‘-a filepath’

Add filepath (file, folder, or wildcard) to the deployable archive. For standalone (-m) builds, files are copied into <output>_mccfiles/ alongside dependency .m files; the generated run_<output>.sh launcher exports NEXUS_MCC_BUNDLE so data files are on the search path (e.g. imread by basename). Folders are included recursively with the subtree preserved; wildcards match files in one folder only (MATLAB R2026a mcc -a semantics).

‘-Z ctf:archive.ctf’

Pack the input and -a files into a ZIP-based CTF archive at archive.ctf. Does not require -m. The archive contains a manifest.json and the packaged sources under matlab/. Extract with unzip / unpack and run from the extracted tree.

‘-v’
‘--verbose’

Verbose mode - echo commands as they are executed.

‘-R option’

Runtime options (currently limited support).

‘-I dir’

Add directory to include path for dependency resolution.

‘file’

One or more .m files to compile. The first file is treated as the main entry point.