Best practice for adding program path for programs intended for compiling

3 views (last 30 days)
My software for data analysis has grown to a fairly big size, and is split to several subdirectories,
like /MATLAB/Myprogram, /MATLAB/Myprogram/GUI
and some others. Normally, I just list the paths to startup.m,
path(path,'/MATLAB/Myprogram')
path(path,'/MATLAB/Myprogram/GUI')
and so on. This works fine, but when I compile the software (to be used with MRE), a bunch of warnings are created,
as this is considered bad programming practice for programs intended for compiling (I agree with that). However, the problem is that I HAVE NOT FOUND AN OBVIOUS ALTERNATIVE WAY of telling MATLAB where to find the functions and classes!
What would that be?

Answers (1)

Rishav
Rishav on 17 Apr 2024 at 8:24
Hi Mikael,
I understand that you want to know the best practice to add the program path for programs intended for compilation.
Instead of dynamically adding paths at runtime, you can set up your paths statically before compilation. You can do this by organizing your code as suggested above and then using the 'mcc' command (MATLAB Compiler Command) with the '-a' option to explicitly add any additional files or folders that are not automatically included due to direct referencing in your code. For example:
mcc -m MyMainScript.m -a /path/to/additional/files
This tells the compiler explicitly about additional files or directories to include in the compilation.
You can also refer to the below mentioned documentation on mcc Comand Line Arguments:

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!