I have a Matlab script go.m
that creates custom objects and runs
a suite of simulations. There is interest in porting it to
a different network where the Matlab licenses are few. Our
strategy is to compile the script into a stand-alone *.exe
so that it can run without using up licenses. Once I figure
out all the ropes, the Matlab Compiler Runtime will be installed
on the target system.
I managed to use command-line mcc
to compile the TMW online example,
magicsquare.
Using cygwin
's bash:
$ cd ~/bin
$ ln -s "/c/Program Files/MATLAB/Single_R2015b/bin/mcc.bat" mcc
$ cd ~/tmp/magicSqr
$ mcc -m magicsquare.m
# startup.m messages indicate that this launches Matlab
$ ./magicsquare.exe 5
Running C:\cygwin64\tmp\User.Name\mcrCache9.0\magics1\Users\User.Name\Documents\MATLAB\startup
m = 17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Both the directory specification .
and the file extension .exe
are needed.
My next step was to push the full-blown go.m
through the
process, see what breaks, and find the least onerous way to deal with
it. By least onerous, I mean a strategy that requires fewest code
modifications so that I'm not maintaining separate code bases for
development versus for porting to the destination.
The mcc
compilation worked: mcc -m go.m
. Running the *.exe
file, however, led to breakage at the very first executable statement:
profile off
. As I said, tactically recoding on an individual basis
is very unpalatable, so I searched for a way to identify all the files
to include when running mcc
. Two promising leads were inmem
and
requiredFilesAndProducts
.
However, the above webpage also warns:
Do not use the Dependency Report to determine which MATLAB code files someone else needs to run a particular file. Instead use the matlab.codetools.requiredFilesAndProducts function.
It appears that the Dependency Report to be avoided refers to the
mfiles output from inmem
. This is corroborated by examination of
said m-files -- the list is extremely long, and includes functions
that befuddle even Matlab's which
command:
>> which matricize
'matricize' not found.
The only other candidate for identifying m-files to include is the
fList output from requiredFilesAndProducts
. It seems to include
all the methods for my custom classes, as well all invoked m-files
residing in c:\Users\User.Name\Documents\MATLAB\
(the only
custom folder in my path). However, it certainly does not cover the
profile
command that underlies the aforementioned error.
What is the best way to identify all the m-files and/or folders
thereof for mcc
? Is it reasonable to then treat any remaining
error-causing statements using conditional execution, e.g., if
~isdeployed; <...problematic statements...>; end
?
You may refer to the list on the documentation page here regarding information on unsupported functions to be compiled with MATLAB Compiler and MATLAB Compiler SDK products: https://www.mathworks.com/help/compiler/unsupported-functions.html
This page below also shows the compatibility with MATLAB Compiler with each individual toolboxes: https://www.mathworks.com/products/compiler/supported/compiler_support.html