a problem when using mcc -m

13 views (last 30 days)
Yang
Yang on 9 Jan 2014
Edited: Jairo A Sandoval on 6 Oct 2017
I am trying to generate .exe file from .m file using mcc -m. I use a toolbox (PRTools) in my .m file. The original .m file runs fine in matlab, but when I run mcc -m fileName.m, I get a lot of warnings like:
Warning: Requirements cannot analyze P-code unless the user provides a corresponding M-code along with the P-code in the same folder. The dependencies of ...\prtools\prtools\@prdataset\prdataset.p may not be included in the completion, because its corresponding M-code found by REQUIREMENTS either is empty or contains nothing but comments.
And when I run the generated .exe file, error reports:
error using prmapping line 128
Not enough input arguments.
...\prtools\prtools\@prdataset\prdataset.p\prdataset line 86
Is it because some functions in the toolbox only have p code? I am not sure because I did a simple test: I write two functions; convert them to p code; delete the original m code; call the two functions in a main file and compile the main file to a .exe file. There are no warnings and this .exe file runs fine.

Answers (2)

Anders Ueland
Anders Ueland on 17 Apr 2016
Edited: Anders Ueland on 17 Apr 2016
Probably too late, but I encountered the same problem today, so thought I post my response anyway.
While .m code is parsed on run-time .p code is parsed before it is run. This makes it impossible for MCC to figure out which dependencies the .p file has.
I suspect that your simple test program dont depend on other m-files(?). That is why you dont get any errors during.
A very hackish solution is to add all the .m files in the prtools folder to the list of files that should be compiled. This will probably include all the files that is used in the other prtools functions.
An even more hackish implementation of this is to loop through all the files in the prtools folder and use eval to execute the compilation. Some files gave an error in the mcc, so they are removed from the list. Worked for me.
allFilesInPRToolsFolder = '';
files = dir('PATH_TO_PRTOOLS_FOLDER');
for i = 1:length(files)
% Only add -m files (with some exceptions)
if ~files(i).isdir & ...
files(i).name(end-1:end) == '.m' & ...
files(i).name(1) ~= '.' &...
~numel(strfind(files(i).name,'Readme.m')) & ...
~numel(strfind(files(i).name,'baggingc.m')) & ...
~numel(strfind(files(i).name,'Contents.m')) & ...
~numel(strfind(files(i).name,'datafiles.m')) & ...
~numel(strfind(files(i).name,'datasets.m')) & ...
~numel(strfind(files(i).name,'mappings.m')) & ...
~numel(strfind(files(i).name,'mtimes.m')) & ...
~numel(strfind(files(i).name,'multi_labeling.m')) & ...
~numel(strfind(files(i).name,'svcinfo.m'))
allFilesInPRToolsFolder = [allFilesInPRToolsFolder ' ' files(i).name(1:end-2)];
end
end
eval(['mcc -options YOUR_FUNCTION prdatafile prdataset prmapping' allFilesInPRToolsFolder ' -N -p PATH_TO_PRTOOLS_FOLDER' ])

Jairo A Sandoval
Jairo A Sandoval on 6 Oct 2017
Edited: Jairo A Sandoval on 6 Oct 2017
Use the "-a" option of MCC to append the path where the .p files reside. For example:
mcc -m hello.m -a ..\Folder1\Folder2\pFiles
Note that any other .m files in the appended folder will be included in the solution and they will have precedence over the MATLAB path (files in the appended folder will shadow other files in the path).
See the MCC documentation for mode details.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!