Main Content

mclInitializeApplication

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

Description

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 char* C-style strings (possibly of zero length) specifying additional MATLAB Runtime options and a count specifying the size of the string array.

example

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[] = {"-logfile", "mylogfile.txt"};
if (! mclInitializeApplication(args, 2))
{
   fprintf(stderr, 
           "An error occurred while initializing.");
   return -1;  
}

Input Arguments

collapse all

MATLAB Runtime options, specified as an array of char* C-style strings. The array may contain the following MATLAB command line switches.

  • -automation

  • -jdb portnumber

  • -logfile filename

  • -noFigureWindows

  • -nosplash

  • -r statement

  • -regserver

  • -softwareopengl

  • -unregserver

In addition to the above, the following options are valid on Linux®.

  • -debug

  • -display xDisp

  • -nodisplay

  • -nojvm

  • -singleCompThread

The switches have the same meaning as they do when used in MATLAB. For details, see the matlab function for your platform.

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 initialization was successful. If the function returns false, calling any further compiled functions results in unpredictable behavior.

Version History

Introduced in R2009a

Go to top of page