Main Content

MATLAB Runtime Startup Options

R2026b

Set Startup Options Using mcc -R

You can use the mcc command with the -R flag to provide MATLAB® Runtime options that are passed to the application at initialization time. This option is only used when building standalone applications or Excel® add-ins.

You can specify the following options using -R.

Option

Description

Target

'-logfile,filename'

Specify a log file name. The file is created in the application folder at runtime and contains information about MATLAB Runtime initialization and all text piped to the command window. Option must be in single quotes. Use double quotes when executing the command from a Windows® Command Prompt.

If a file path is specified, the path must exist and must not include environment variables.

MATLAB Compiler™

-nodisplay

(Linux® only) Open MATLAB Runtime without display functionality. Suppress the MATLAB nodisplay run-time warning.

MATLAB Compiler

-nojvm

Do not use the Java® Virtual Machine (JVM). Deployed applications that use Java functionality produce a runtime error.

MATLAB Compiler

'-startmsg,message'

Customizable user message displayed at initialization time.

MATLAB Compiler Standalone Applications

'-completemsg,message'

Customizable user message displayed when initialization is complete.

MATLAB Compiler Standalone Applications

-singleCompThread

Limit MATLAB to a single computational thread.

MATLAB Compiler

For full details, see mcc -R.

Display MATLAB Runtime Initialization Messages

You can display a console message for end users that informs them when MATLAB Runtime initialization starts and completes.

To create these messages, use the -R option of the mcc command.

You have the following options:

  • Use the default startup message only (Initializing MATLAB runtime version x.xx)

  • Customize the startup or completion message with text of your choice. The default startup message will also display prior to displaying your customized startup message.

When calling mcc in the MATLAB command window, place the comma inside the single quote.

mcc -m hello.m -R '-startmsg,"Message_Without_Space"'

If your initialization message has double quotes in it, escape each quote by preceding it with a backslash. If your initialization message has a space in it, call mcc from the system command window or use !mcc from MATLAB.

Some examples of different ways to invoke this option follow.

This command:Displays:
mcc -R -startmsgDefault startup message Initializing MATLAB Runtime version x.xx
mcc -R -startmsg,'user customized message'Default startup message Initializing MATLAB Runtime version x.xx and user customized message for startup
mcc -R -completemsg,'user customized message'Default startup message Initializing MATLAB Runtime version x.xx and user customized message for completion
mcc -R -startmsg,'user customized message' -R -completemsg,'user customized message' Default startup message Initializing MATLAB Runtime version x.xx and user customized message for both startup and completion by specifying -R before each option
mcc -R -startmsg,'user customized message',-completemsg,'user customized message'Default startup message Initializing MATLAB Runtime version x.xx and user customized message for both startup and completion by specifying -R only once

Retrieve MATLAB Runtime Startup Options

Use these functions to return data about the MATLAB Runtime state when working with shared libraries.

Function and SignatureWhen to UseReturn Value
bool mclIsMCRInitialized()Use mclIsMCRInitialized() to determine whether or not the MATLAB Runtime has been properly initialized.Boolean (true or false). Returns true if MATLAB Runtime is already initialized, else returns false.
bool mclIsJVMEnabled()Use mclIsJVMEnabled() to determine if the MATLAB Runtime is started with an instance of a Java Virtual Machine (JVM®).Boolean (true or false). Returns true if MATLAB Runtime has been started with a JVM instance, else returns false.
const char* mclGetLogFileName()Use mclGetLogFileName() to retrieve the name of the log file used by the MATLAB Runtime.Character string representing log file name used by the MATLAB Runtime, preceded by the character.
bool mclIsNoDisplaySet()Use mclIsNoDisplaySet() to determine if -nodisplay option is enabled.Boolean (true or false). Returns true if -nodisplay is enabled, else returns false.

Note

false is always returned on Windows systems since the -nodisplay option is not supported on Windows systems.

When running on Mac, if -nodisplay is used as one of the options included in mclInitializeApplication, then the call to mclInitializeApplication must occur before calling mclRunMain.

Note

All of these attributes have properties of write-once, read-only.

Retrieve Information About MATLAB Runtime Startup Options

The following example demonstrates how to pass options to a C or C++ shared library and how to retrieve the corresponding values after they are set.

 const char* options[4];     
    options[0] = "-logfile";    
    options[1] = "logfile.txt";
    options[2] = "-nojvm";
    options[3] = "-nodisplay"; 
    if( !mclInitializeApplication(options,4) )
    {
        fprintf(stderr, 
                "Could not initialize the application.\n");
        return -1;
    }
    printf("MCR initialized : %d\n", mclIsMCRInitialized());
    printf("JVM initialized : %d\n", mclIsJVMEnabled());
    printf("Logfile name : %s\n", mclGetLogFileName());
    printf("nodisplay set : %d\n", mclIsNoDisplaySet());
    fflush(stdout);

See Also

Topics