主要内容

mclInitializeApplication

设置在当前进程中创建的所有 MATLAB Runtime 实例共享的应用程序状态

说明

bool mclInitializeApplication(const char **options, int count) 设置在当前进程中创建的所有 MATLAB® Runtime 实例共享的应用程序状态。该函数接受用于指定附加 MATLAB Runtime 选项的 char* C 样式的字符串数组(长度可能为零)以及用于指定该字符串数组大小的计数。

示例

示例

全部折叠

在 C/C++ 应用程序代码的主函数中,调用 mclInitializeApplication 来启动所有 MATLAB Runtime 实例:

/* 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;
}

小心

每个进程只能调用 mclInitializeApplication 一次。多次调用 mclInitializeApplication 可能会导致应用程序出现不可预测或异常的行为。

在 C/C++ 应用程序代码的主函数中,调用 mclInitializeApplication 来使用 -nodisplay 选项启动所有 MATLAB Runtime 实例:

const char *args[] = {"-logfile", "mylogfile.txt"};
if (! mclInitializeApplication(args, 2))
{
   fprintf(stderr, 
           "An error occurred while initializing.");
   return -1;  
}

输入参数

全部折叠

MATLAB Runtime 选项,指定为 char* C 样式的字符串数组。该数组可包含以下 MATLAB 命令行开关。

  • -automation

  • -jdb portnumber

  • -logfile filename

  • -noFigureWindows

  • -nojvm

  • -nosplash

  • -r statement

  • -regserver

  • -softwareopengl

  • -unregserver

  • -singleCompThread

除上述选项外,以下选项在 Linux® 上也是有效的。

  • -debug

  • -display xDisp

  • -nodisplay

这些开关的含义与在 MATLAB 中使用时相同。有关详细信息,请参阅适用于您的平台的 matlab 函数。

小心

Mac 上运行时,如果 -nodisplay 用作 options 中包含的选项之一,则必须在调用 mclRunMain 之前调用 mclInitializeApplication

示例: {"-singleCompThread", "-nodisplay"}

options 字符串数组的大小,指定为整数。

示例: 2

输出参量

全部折叠

初始化结果,以布尔值形式返回。结果指示初始化是否成功。如果该函数返回 false,则调用任何后续编译函数都会导致不可预测的行为。

版本历史记录

在 R2009a 中推出