Main Content


Mechanism for creating identical wrapper code across all platforms


typedef int (*mclMainFcnType)(int, const char **);

int mclRunMain(mclMainFcnType run_main,
               int argc,
               const char **argv)


As you need to provide wrapper code when creating an application which uses a C or C++ shared library created by MATLAB® Compiler SDK™, mclRunMain enables you with a mechanism for creating identical wrapper code across all MATLAB Compiler SDK platform environments.

mclRunMain is especially helpful in Macintosh OS X environments where a run loop must be created for correct MATLAB Runtime operation.

When a Mac OS X run loop is started, if mclInitializeApplication specifies the -nojvm or -nodisplay option, creating a run loop is a straightforward process. Otherwise, you must create a Cocoa framework. The Cocoa frameworks consist of libraries, APIs, and MATLAB Runtime that form the development layer for all of Mac OS X.

Generally, the function pointed to by run_main returns with a pointer (return value) to the code that invoked it. However, when using Cocoa on the Macintosh, when the function pointed to by run_main returns, MATLAB Runtime calls exit before the return value can be received by the application because the underlying code cannot get control when Cocoa is shut down.


You should not use mclRunMain if your application brings up its own full graphical environment.


In non-Macintosh environments, mclRunMain acts as a wrapper and does not perform any significant processing.



Name of function to execute after MATLAB Runtime set-up code.


Number of arguments being passed to run_main function. Usually, argc is received by application at its main function.


Pointer to an array of character pointers. Usually, argv is received by application at its main function.


Call using this basic structure:

int returncode = 0;
returncode = mclRunMain((mclmainFcn)

Version History

Introduced in R2010b