Main Content

mclInitializeApplication

Set up application state shared by all MATLAB Runtime instances created in current process

Description

example

bool mclInitializeApplication(const char **options, int count) sets up the application state shared by all MATLAB® Runtime instances created in the current process. The function takes an array of strings (possibly of zero length) specifying additional MATLAB Runtime options and a count specifying the size of the string array.

Examples

collapse all

In the main function of your C/C++ application code, call mclInitializeApplication to start all MATLAB Runtime instances:

/* Call the mclInitializeApplication routine. Make sure that the application
 * was initialized properly by checking the return status. This initialization
 * has to be done before calling any MATLAB APIs or MATLAB Compiler SDK
 * generated shared library functions.
 */ 
if (!mclInitializeApplication(nullptr, 0))
{
	std::cerr << "Could not initialize the application." << std::endl;
	return -1;
}

Caution

mclInitializeApplication must be called once only per process. Calling mclInitializeApplication more than once may cause your application to exhibit unpredictable or undesirable behavior.

In the main function of your C/C++ application code, call mclInitializeApplication to start all MATLAB Runtime instances with the -nodisplay option:

const char *args[] = { "-nodisplay" }; 
if (! mclInitializeApplication(args, 1))
{
   fprintf(stderr, 
           "An error occurred while initializing: \n %s ",
           mclGetLastErrorMessage());
   return -1;  
}

Input Arguments

collapse all

MATLAB Runtime options, specified as a string array. The string array may contain the following MATLAB command line switches, which have the same meaning as they do when used in MATLAB:

  • -appendlogfile

  • -Automation

  • -beginfile

  • -debug

  • -defer

  • -display

  • -Embedding

  • -endfile

  • -fork

  • -java

  • -jdb

  • -logfile

  • -minimize

  • -MLAutomation

  • -nodisplay

  • -noFigureWindows

  • -nojvm

  • -noshelldde

  • -nosplash

  • -r

  • -Regserver

  • -shelldde

  • -singleCompThread

  • -Unregserver

  • -useJavaFigures

  • -mwvisual

  • -xrm

Caution

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

Example: {“-singleCompThread”, ”-nodisplay”}

Size of the options string array, specified as an integer.

Example: 2

Output Arguments

collapse all

Initialization result, returned as a boolean value. Result indicates whether or not mcli initialization was successful. If the function returns false, calling any further compiled functions results in unpredictable behavior.

Version History

Introduced in R2009a