How do I use the mclInitializeApplication function to make a C-shared library that does not use the JVM or JIT in MATLAB 7.0 (R14)?

4 views (last 30 days)
I am using MATLAB Compiler 4.0 (R14), and I would like to make a C-shared library that does not use the Java Virtual Machine (JVM) or the Just-In-Time (JIT) accelerator. How can I do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 26 Apr 2023
Edited: MathWorks Support Team on 26 Apr 2023
The C/C++ shared libraries created with the MATLAB Compiler can be run in "nojvm" and/or "nojit" mode.
This is accomplished through the use of the mclInitializeApplication function. The function signatures for this function is as follows:
 
bool mclInitializeApplication(const char **options, int count);
In other words, mclInitializeApplication takes an array of strings of user-settable options and a count of the number of options (the length of the option array). This function returns true (1) for success and false (0) for failure.
To specify that the library should not use the Java Virtual Machine, the option string is "nojvm". To specify that the library should not use the JIT, use the option string "nojit" .
The use of these options is illustrated in the following example, where a MATLAB-generated library named "hello" is called
int main()
{
char *pStrings[]={"-nojvm","-nojit"};
if (!mclInitializeApplication(pStrings,2))
{
fprintf(stderr, "Could not initialize MCR for the application.\n");
return -1;
}
if(!helloInitialize())
{
fprintf(stderr, "Could not initialize the library.\n");
return -1;
}
mlfHello();
helloTerminate();
mclTerminateApplication();
return 0;
}
For more information about calling a MATLAB-generated shared library, see the "C Shared Library Example" section of the MATLAB Compiler SDK documentation:

More Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!