Dependency errors on import class statement when compiling with mcc

8 views (last 30 days)
However, I open a new question since the other question has been marked as answered, even if the problem persists.
Background
I am working on a large simulation software that contains many classes and files organized in folders and subfolders. The parent folders are included in the path options passed to the compiler with the -p option. I need to compile the software to be able to run it on a computation cluster without using Matlab licenses which are limited in my research institute.
Note: All the examples from PATH_TO/matlab/R2014a/extern/examples/compiler could be compiled successfully and passed the tests in my environment, using the compiler from version R2014a.
The code runs successfully in a desktop Matlab session.
Matlab version 2014a 8.3.0
Matlab MCR version 8.3
Linux 64 bits
gcc version 4.7.2
Problem
When compiling with command
mcc -o runSimulation -W main:runSimulation -T link:exe -d ./bin/runSimulation -p bioinfo -p curvefit -p images -p optim -p signal -p stats -N -w enable:specified_file_mismatch -w enable:repeated_file -w enable:switch_ignored -w enable:missing_lib_sentinel -w enable:demo_license -R -nodisplay -R -singleCompThread -v ./bin/runSimulation.m -a LONG_LIST_OF_ALL_MATLAB_FILES
I always get dependencies error like:
Error using getSymbolNames (line 145) Import argument "SOME_CLASS_NAME" in MATLAB code 'SOME_MATLAB_FILE.m' cannot be found or cannot be imported.
Error in matlab.depfun.internal.MatlabInspector/analyzeSymbols (line 152) [F, S] = getSymbolNames(symbol.WhichResult);
Error in matlab.depfun.internal.Completion/findDependentFiles (line 1057) analyzeSymbols(inspector, symbol);
Error in matlab.depfun.internal.Completion/computeDependencies (line 234) findDependentFiles(obj);
Error in matlab.depfun.internal.Completion/computePartsList (line 1581) computeDependencies(obj);
Error in matlab.depfun.internal.Completion/requirements (line 1890) parts = computePartsList(obj, false);
Error in matlab.depfun.internal.requirements (line 191) [parts, resources.products, resources.platforms] = c.requirements();
Unexpected error while determining required deployable files. Compilation terminated.
What I tried to solve the problem
I tried to include ALL the subfolders (not only the parent folders) by passing them with the -p option or the -I option to the compiler.
I tried to change the order of the files passed the compiler. In this case I get the same error but referring to another import statement in a different file.
In a Matlab desktop session, by setting the correct paths with the addpath() function, I can import the mentionned class without any problem. Therefore, it seems to be a problem related to the Matlab compiler.
If I comment out the import statement and use the absolute package prefix for the external class the error disappears in the compiler. However, this would be a very bad solution since it implies manually correcting all the import statements, substituting class names with their prefix in all files.

Accepted Answer

Marc Weber
Marc Weber on 16 Jul 2015
I resolved the problem with the help of Matlab technical staff. There was an error in the compiling command: I was passing all the matlab .m files to the compiler with the -a option. This created a conflict with the dependency routine. Quoting the technical staff:
"Generally speaking you should not need the -a option to add additional M-, P- or MEX-file to the application. The dependency analysis should automatically find all the M-files which your project requires. Only if you make use "eval" or "feval" or if you have defined string callbacks or you load a MAT-file containing MATLAB Objects you may need -a. Further -a can be used to add non-executable resources (MAT-files, images, etc.) to your project."
Removing all the -a options solved the problem and now the program compiles correctly.

More Answers (0)

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!