Alex Botev
Alex Botev

Reputation: 1399

Matlab Compiler and Startup script

So I'm trying to use the Matlab Compiler in order to build a standalone application which to run on a separate machine using MCR. The actual application follows this guide to benchmark GPU. When I open matlab following this I make the following command:

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

The output is:

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").

Than on the other machine, given that the environmental variables are set I just execute the command

./gpuTest

The resulting error is:

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

Problem is there is no "startup" script from the one that should have been compiled. However I do have a "startup.m" script which in my startup folder which in fact exactly executes "cd /media/hdd/work/matlab" and some other stuff.

I have 2 questions:

  1. Why the heck is it compiling also my startup script at all?
  2. How can I fix this to just execute the main script?

Upvotes: 1

Views: 518

Answers (2)

Sam Roberts
Sam Roberts

Reputation: 24127

To answer both your questions:

  1. It's compiling your startup.m script so that it can ensure that your main script runs exactly the same as it would in your regular MATLAB session. You'll find that it also includes a bunch of other stuff as well that's needed, such as your preferences folder, which is again needed to ensure that it runs the same as it does in a regular MATLAB session.
  2. @matlabgui has already provided a similar answer, which is to apply isdeployed within your startup script to block out anything that you don't want to run in the deployed version. Personally, I usually put the following at the top of my startup script, to just block everything.

startup.m

if isdeployed
    return
end

Upvotes: 2

matlabgui
matlabgui

Reputation: 5672

change your startup script to have:

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

Why - I dont really know - I guess its so you could initiaise some stuff but its not a "feature" that I have ever utilized....

Upvotes: 0

Related Questions