Reputation: 23
I have a MATLAB script that I have to compile for deployment. I'm using the command 'mcc', however, I also need to include the toolboxes: PRTools (http://37steps.com/software/) and dd_tools (http://prlab.tudelft.nl/david-tax/dd_tools.html). I'm trying to include using the command addpath(), it does not work. I have no idea how to include those toolboxes. I tried to use:
if ~isdeployed
addpath PRTools
addpath dd_tools
end
but it does not work as well.
Upvotes: 2
Views: 781
Reputation: 65430
For deployment with mcc
, you should add the paths to your MATLAB path (using pathtool
or addpath
) before compiling the application rather than calling addpath
from within your code.
mcc
statically analyzes your code to determine what needs to be included in the executable. Part of this static code analysis includes finding all function calls within your code and locating the corresponding source files. Since you are calling addpath
from within your code, MATLAB is unable to properly locate all of the toolbox functions (since they are added to the path dynamically at run-time and the code is analyzed statically) and will omit these files.
If you add them to your MATLAB path first, mcc
will be able to statically analyze your code, locate all needed toolbox functions, and include them in the resulting executable.
A cleaner alternative to modifying your path is to use the -I
option when calling mcc
to specify a specific folder to include.
-I
Add a new folder path to the list of included folders. Each-I
option adds a folder to the beginning of the list of paths to search. For example,
-I <directory1> -I <directory2>
sets up the search path so that
directory1
is searched first for MATLAB files, followed bydirectory2
. This option is important for standalone compilation where the MATLAB path is not available.
For your case this would be something like
mcc -m main.m -I PRTools -I dd_tools
Upvotes: 5