Main Content

Dependency Analysis Function and User Interaction with the Compilation Path

addpath and rmpath in MATLAB

MATLAB® Compiler™ uses the MATLAB search path to analyze dependencies. See addpath, rmpath, savepath for information on working with the search path.

Note

mcc does not use the MATLAB startup folder and will not find any path information saved there.

Passing -I <directory> on the Command Line

You can use the -I option to add a folder to the beginning of the list of paths to use for the current compilation. This feature is useful when you are compiling files that are in folders currently not on the MATLAB path.

Passing -N and -p <directory> on the Command Line

There are two MATLAB Compiler options that provide more detailed manipulation of the path. This feature acts like a “filter” applied to the MATLAB path for a given compilation. The first option is -N. Passing -N on the mcc command line effectively clears the path of all folders except the following core folders (this list is subject to change over time):

  • matlabroot\toolbox\matlab

  • matlabroot\toolbox\local

  • matlabroot\toolbox\compiler\deploy

  • matlabroot\toolbox\compiler

It also retains all subfolders of the above list that appear on the MATLAB path at compile time. Including -N on the command line allows you to replace folders from the original path, while retaining the relative ordering of the included folders. All subfolders of the included folders that appear on the original path are also included. In addition, the -N option retains all folders that the user has included on the path that are not under matlabroot\toolbox.

Use the -p option to add a folder to the compilation path in an order-sensitive context, i.e., the same order in which they are found on your MATLAB path. The syntax is

p <directory>

where <directory> is the folder to be included. If <directory> is not an absolute path, it is assumed to be under the current working folder. The rules for how these folders are included are

  • If a folder is included with -p that is on the original MATLAB path, the folder and all its subfolders that appear on the original path are added to the compilation path in an order-sensitive context.

  • If a folder is included with -p that is not on the original MATLAB path, that folder is not included in the compilation. (You can use -I to add it.)

  • If a path is added with the -I option while this feature is active (-N has been passed) and it is already on the MATLAB path, it is added in the order-sensitive context as if it were included with -p. Otherwise, the folder is added to the head of the path, as it normally would be with -I.

    Note

    The -p option requires the -N option on the mcc command line.