Compiling large nested folder structure

4 views (last 30 days)
Hello,
I am having an issue when compiling a large and deep structure where some of the m files on nested folders do not get added.
Example:
Structre:
a/file1.m
b/file2.m
b/A/file3.m
b/B/file4.m
b/B/x/file5.m
b/B/y/file6.m
b/B/z/file7.m
b/C/file8.m
b/D/file9.m
c/file10.m
d/file11.m
e/file12.m
Compilation:
mcc -o test.exe -W WinMain:file1.m -T link:exe -v a/file1.m -a ./*.m
Error:
When the binary is then executed, is missing the nested *.m files file5.m, file6.m, file7.m
Is there any solution to this?

Answers (2)

Mohammad Sami
Mohammad Sami on 11 Sep 2020
You need to add the folder and sub folders to the path before compiling. Example add folder b and all its sub folders to the path. addpath(genpath('b'));
  1 Comment
Francesc Massanes Basi
Francesc Massanes Basi on 11 Sep 2020
That is a good answer, but only if you are running it from inside of matlab, if you are compiling from command line, this does not work.

Sign in to comment.


Image Analyst
Image Analyst on 11 Sep 2020
If file1.m is your main file, and it's in folder "a", then make "a" your current folder and do
mcc file1.m -o test.exe -W WinMain:file1.m -T link:exe -v
You don't need to explicitly list all the dependent m-files. The compiler will find them automatically, just as MATLAB did when you ran the file1.m file in the development environment because they are on your search path.
I'm not sure what the -W and -T options are - you may not need them. I never use them.
  3 Comments
Mohammad Sami
Mohammad Sami on 11 Sep 2020
Yes as mentioned you need to add all folders and subfolder to the path, so that compiler can find all the files.
Image Analyst
Image Analyst on 11 Sep 2020
If they're not on the path, then how does your main file even run at all? The other 11 files are in different folders, so if they were not on the path, your main program would not run. So somehow they were on the path when your file1.m program ran. Why were they not on the path when you ran the mcc command? Did your file1 program call addpath()? If so, that will throw a warning during compile.

Sign in to comment.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

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

Start Hunting!