Compiling large nested folder structure
8 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
Mohammad Sami
2020-9-11
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'));
Image Analyst
2020-9-11
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 个评论
Mohammad Sami
2020-9-11
Yes as mentioned you need to add all folders and subfolder to the path, so that compiler can find all the files.
Image Analyst
2020-9-11
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!