Matlab编译器和启动脚本

时间:2015-04-09 18:26:35

标签: matlab matlab-deployment matlab-compiler

因此我尝试使用Matlab编译器来构建一个独立的应用程序,该应用程序使用MCR在单独的计算机上运行。实际应用程序遵循此guide来标记GPU。当我在this之后打开matlab时,我发出以下命令:

mcc -mv -o gpuTest mainBench.m benchFcn.m executeBenchmarks.m getData.m paralleldemo_gpu_backslash.m timeSolve.m waitForCpu.m waitForGpu.m

输出结果为:

Compiler version: 5.1 (R2014a)
Dependency analysis by REQUIREMENTS.
Parsing file "/media/hdd/work/matlab/gpuBench/mainBench.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/benchFcn.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/executeBenchmarks.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/getData.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/paralleldemo_gpu_backslash.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/timeSolve.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/waitForCpu.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/waitForGpu.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/opt/MATLAB/R2014a/toolbox/compiler/deploy/deployprint.m"
    (Referenced from: "Compiler Command Line").
Parsing file "/opt/MATLAB/R2014a/toolbox/compiler/deploy/printdlg.m"
    (Referenced from: "Compiler Command Line").

在另一台机器上,假设设置了环境变量,我只执行命令

./gpuTest

产生的错误是:

Cannot CD to /media/hdd/work/matlab (Name is nonexistent or not a directory).    
Error in startup (line 1)

问题是没有"启动"应该编译的脚本。但是我确实有一个" startup.m"在我的启动文件夹中的脚本实际上正好执行" cd / media / hdd / work / matlab"和其他一些东西。

我有两个问题:

  1. 为什么要编译我的启动脚本呢?
  2. 如何修复此问题才能执行主脚本?

2 个答案:

答案 0 :(得分:2)

回答你的两个问题:

  1. 它正在编译您的startup.m脚本,以便确保您的主脚本与常规MATLAB会话中的脚本运行完全相同。您会发现它还包含一些其他所需的内容,例如您的首选项文件夹,再次需要它来确保它与常规MATLAB会话中的运行方式相同。
  2. @matlabgui已经提供了类似的答案,即在您的启动脚本中应用isdeployed来阻止您不希望在已部署版本中运行的任何内容。就个人而言,我通常将以下内容放在启动脚本的顶部,以阻止所有内容。
  3. startup.m

    if isdeployed
        return
    end
    

答案 1 :(得分:0)

将您的启动脚本更改为:

if ~isdeployed
   cd /media/hdd/work/matlab
end

为什么 - 我真的不知道 - 我想它是这样你可以初始化一些东西,但它不是"功能"我曾经用过....