Compiling large nested folder structure

조회 수: 10 (최근 30일)
Francesc Massanes Basi
Francesc Massanes Basi 2020년 9월 11일
댓글: Image Analyst 2020년 9월 11일
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?

답변 (2개)

Mohammad Sami
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'));
  댓글 수: 1
Francesc Massanes Basi
Francesc Massanes Basi 2020년 9월 11일
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.

댓글을 달려면 로그인하십시오.


Image Analyst
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
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by