【问题标题】:Matlab Compiler and Startup scriptMatlab 编译器和启动脚本
【发布时间】:2015-04-09 18:26:34
【问题描述】:

所以我正在尝试使用 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. 如何解决此问题以仅执行主脚本?

【问题讨论】:

    标签: matlab matlab-deployment matlab-compiler


    【解决方案1】:

    回答您的两个问题:

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

    startup.m

    if isdeployed
        return
    end
    

    【讨论】:

      【解决方案2】:

      将您的启动脚本更改为:

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

      为什么-我真的不知道-我想它是为了让您可以启动一些东西,但它不是我曾经使用过的“功能”....

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多