The ability to create the output directory specified using the "-d" option in the MCC command if it does not exist is not available in MATLAB Compiler 4.11 (R2009b).
To work around the issue, you can perform the following steps:
1. If you are using the MCC command to compile MATLAB functions directly, you create use the MKDIR command as specified below:
myDir = 'C:\work\myDir';
mkdir(myDir);
mcc('-m', 'myFunc.m', '-v', '-d', myDir);
2. If you are using the MCC command to compile a project file created using DEPLOYTOOL, you can use the following code to parse the project file and create the "src" and "distrib" directories.
s = 'myApp.prj';
prjFileName = s;
prj=xmlread(s);
s=['mcc -F ' s];
pathStr = fileparts( which(prjFileName) );
src_dir = prj.getElementsByTagName('intermediate_dir');
src_dir = src_dir.item(0).getFirstChild.getData;
src_dir = char(src_dir);
if ~isempty( regexp(src_dir, '\$\(PROJECTDIR\)', 'once') )
src_dir = regexprep(src_dir, '\$\(PROJECTDIR\)', '');
src_dir = fullfile(pathStr, src_dir);
end
mkdir(src_dir);
distrib_dir = prj.getElementsByTagName('output_dir');
distrib_dir = distrib_dir.item(0).getFirstChild.getData;
distrib_dir = char(distrib_dir);
if ~isempty( regexp(distrib_dir, '\$\(PROJECTDIR\)', 'once') )
distrib_dir = regexprep(distrib_dir, '\$\(PROJECTDIR\)', '');
distrib_dir = fullfile(pathStr, distrib_dir);
end
mkdir(distrib_dir);
eval(s)
Best Answer